Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tabbar height #91

Open
reflash opened this issue Jan 1, 2025 · 0 comments
Open

Tabbar height #91

reflash opened this issue Jan 1, 2025 · 0 comments

Comments

@reflash
Copy link

reflash commented Jan 1, 2025

Hello,
I'm trying to use Tabbar component for my app, the issue I'm having is I'm not able to properly determine tabbar height, so I could position other elements properly and it seems that tabbar doesn't have a "ref" prop so I could hack it in some way.
Maybe I'm using it absolutely wrong, so please advise on that:

const tabs = [
  { id: 'tab1', text: 'Tab1', icon: 'icon1' },
  { id: 'tab2', text: 'Tab2', icon: 'icon2' },
  { id: 'tab3', text: 'Tab3', icon: 'icon3' }
];

export const IndexPage: FC = () => {
  const [currentTab, setCurrentTab] = useState(tabs[0].id);
  const [tabbarHeight, setTabbarHeight] = useState(0);
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    if(ref.current) setTabbarHeight(ref.current.clientHeight);
  })
  
  return (
    <Page back={false}>
      <Tabbar ref={ref}>
        {tabs.map(({
        id,
        text,
        icon
      }) => <Tabbar.Item key={id} text={text} selected={id === currentTab} onClick={() => setCurrentTab(id)}>
            <Icon icon={icon} />
          </Tabbar.Item>)}
      </Tabbar>
      {currentTab === 'tab1' && <Tab1Page />}
      {currentTab === 'tab2' && <Tab2Page />}
      {currentTab === 'tab3' && <Tab3Page />}
    </Page>
  );

I need the height to position floating components like Floating Action Button and Snackbar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant