flowbite-react icon indicating copy to clipboard operation
flowbite-react copied to clipboard

Programmatically Changing Tabs Component Issue

Open AlexW301 opened this issue 3 years ago • 2 comments

Hi, I am having a problem with your React library changinging the tabs programatically, this example in the react docs does not work. The onActiveTab property doesn't exist and i get an error that I can put a useRef on functional component.

const Tabs: FC = () => {

const [activeTab, setActiveTab] = useState(0);

const tabsRef = useRef(null);

return (

<>

<Tabs.Group

aria-label="Default tabs"

style="default"

ref={tabsRef}

onActiveTabChange={tab => setActiveTab(tab)}

<Tabs.Item active title="Profile">

Profile content

</Tabs.Item>

<Tabs.Item title="Dashboard">Dashboard content</Tabs.Item>

<Tabs.Item title="Settings">Settings content</Tabs.Item>

<Tabs.Item title="Contacts">Contacts content</Tabs.Item>

</Tabs.Group>

Active tab: {activeTab}

<Button.Group>

<Button color="gray" onClick={() => tabsRef.current?.setActiveTab(0)}>

Profile

<Button color="gray" onClick={() => tabsRef.current?.setActiveTab(1)}>

Dashboard

<Button color="gray" onClick={() => tabsRef.current?.setActiveTab(2)}>

Settings

<Button color="gray" onClick={() => tabsRef.current?.setActiveTab(3)}>

Contacts

</Button.Group>

</>

);

};

AlexW301 avatar Jan 25 '23 17:01 AlexW301

Please follow the bug report template. I don't know what is expected, I don't know the version that you are using. Also, the code that you pasted is unreadable. Can you please add some format to it? I want to help, but it needs to be two-way. :)

rluders avatar Jan 26 '23 12:01 rluders

Hi there, let us know if you're still having this issue, and please use the provided template for bug reports, it makes it easier for everybody.

tulup-conner avatar Mar 04 '23 00:03 tulup-conner