Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

sticky navbar in react

const [stickyNav, setStickyNav] = useState<boolean>(false);

  useEffect(() => {
    window.onscroll = () => {
      setStickyNav(window.pageYOffset === 0 ? false : true);
      return () => (window.onscroll = null);
    };
  }, []);
  return (
    <div className={`  w-full top-0  z-[1000] py-4 text-[#FFF] ${stickyNav ? 'bg-primary fixed' : ''} }`}>
      <FlexXBetweenYCenter className="flex items-center justify-between h-full section-wrapper">
		<FlexXBetweenYCenter/>
	</div>
  )

Comment

PREVIOUS NEXT
Code Example
Javascript :: Creating a Proxy Object 
Javascript :: react conditional styling 
Javascript :: submit a form on enter angular 
Javascript :: regex char and number 
Javascript :: date without time js 
Javascript :: add css on click javascript 
Javascript :: js capitalize 
Javascript :: get value of key in object mongodb 
Javascript :: react router dom current path hook 
Javascript :: how to link a photo in expo react native 
Javascript :: jqurey text contains selector 
Javascript :: expo react native 
Javascript :: add active class to li onclick react 
Javascript :: iterate object in react 
Javascript :: javascript element in array 
Javascript :: disable button in swal popup 
Javascript :: get file extension node 
Javascript :: user api testing 
Javascript :: javascript change input value event 
Javascript :: An external JavaScript cannot contain the <script tag 
Javascript :: firestore add document 
Javascript :: iiee javascript 
Javascript :: chrome storage onchanged 
Javascript :: authfunctions 
Javascript :: safeareaview react native android 
Javascript :: get name jquery 
Javascript :: js string to array 
Javascript :: merge 2 dictionaries with same keys javascript 
Javascript :: react refresh 404 error 
Javascript :: Javascript how to differentiate single click event and double click event 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =