Hulian UIv0.93.5413 components0 components
  • Start
  • Components
  • Blocks
  • Pages
  • Demos
  • Changelog
ChineseEnglish
  • ComponentsComponents
  • ThemeTheme

Navigation

  • TabBar
  • Fab

Overlays

  • ActionSheet

Input

  • Picker

Gestures

  • SwipeAction
  • PullToRefresh

Layout

  • SafeArea

TabBar

tab-bar

Provides safe-area-aware bottom navigation for mobile application sections.

Usage

Basic usage

items driver; for uncontrolled use defaultValue Set the initial item, and the active item is highlighted text-primary.

tsx
<TabBar
  defaultValue="home"
  items={[
    { key: "home", label: "Home", icon: <Home /> },
    { key: "find", label: "Discover", icon: <Search /> },
    { key: "me", label: "My", icon: <User /> },
  ]}
/>

Corner mark and red dot

item.badge displays a digital corner mark (priority to dot), item.dot displays a red dot.

tsx
<TabBar
  defaultValue="home"
  items={[
    { key: "home", label: "Home", icon: <Home /> },
    { key: "find", label: "Discover", icon: <Search />, dot: true },
    { key: "plan", label: "Schedule", icon: <Calendar />, badge: 5 },
    { key: "me", label: "My", icon: <User /> },
  ]}
/>

Disabled item

item.disabled is grayed out and unclickable.

tsx
<TabBar
  defaultValue="home"
  items={[
    { key: "home", label: "Home", icon: <Home /> },
    { key: "plan", label: "Schedule", icon: <Calendar />, disabled: true },
    { key: "me", label: "My", icon: <User /> },
  ]}
/>

When to Use

Use it for top-level mobile navigation such as Home, Discover, and Profile. Use Fab for a single contextual action, or ActionSheet for a temporary list of actions.

Import

ts
import { TabBar } from "@hulianui/ui"

Props

NameTypeDefaultDescription
items *TabBarItem[]-Page tag data (see below)
valuestring-Controlled activation key
defaultValuestringFirst keyUncontrolled initial key
safeAreabooleantrueAdds the bottom safe-area inset
fixedbooleantruefixed to the bottom; false to follow the document flow
aria-labelstringLocale valueAccessible navigation landmark label; an explicit value takes precedence.
classNamestring--

TabBarItem

NameTypeDefaultDescription
key *string-Unique key, also the value used by value.
label *ReactNode-Tab text.
iconReactNode-Default-state icon.
activeIconReactNodeReuses iconActive-state icon.
dotbooleanfalseRed-dot indicator.
badgeReactNode-Corner-mark content (number or text); takes precedence over dot.
disabledbooleanfalseDisables the tab.

Events

EventTypeDescription
onChange(key: string) => voidSwitch tab callback

Usage Guidelines

  • Default fixed sticks to the bottom of the viewport + eats the bottom safe area. When putting it into a mobile phone frame/container for demonstration, fixed={false} must be included in the document flow, otherwise it will float to the bottom of the page; add safeArea={false} when no safe area is needed in the container.
  • When badge and dot are supplied at the same time, badge takes priority.
  • The navigation landmark follows ConfigProvider locale; enUS provides “Bottom navigation”, and the no-provider fallback remains Chinese.

Related

Fab · ActionSheet · Picker · SwipeAction · PullToRefresh · SafeArea

PreviousWatchMobileNextFab

On this page

  • Usage
  • Documentation
    • When to Use
    • Import
    • Props
    • Events
    • Usage Guidelines
    • Related