doc.en-US.md 5.3 KB
Newer Older
1
#  Tabbar
O
oasis-cloud 已提交
2

3
### introduce
O
oasis-cloud 已提交
4

5
Bottom Navigation Common Scenarios
O
oasis-cloud 已提交
6

7
### Install
O
oasis-cloud 已提交
8 9 10 11 12

```ts
import { Tabbar, TabbarItem } from '@nutui/nutui-react';
```

13
## code demo
O
oasis-cloud 已提交
14

15
### Basic usage
O
oasis-cloud 已提交
16 17 18 19 20 21

:::demo
```tsx
import  React from "react";
import {  Tabbar, TabbarItem } from '@nutui/nutui-react';

22 23 24 25 26 27
const App = () =>(
  <Tabbar
    tabSwitch={(child, idx) => {
      console.log(idx)
    }}
  >
28
    <TabbarItem tabTitle="first" icon="home" />
29 30
    <TabbarItem tabTitle="Classification" icon="category" />
    <TabbarItem tabTitle="Find" icon="find" />
31
    <TabbarItem tabTitle="cart" icon="cart" />
32
    <TabbarItem tabTitle="mine" icon="my" />
33 34
  </Tabbar>
);
O
oasis-cloud 已提交
35

36
export default App;
O
oasis-cloud 已提交
37 38
```
:::
39
### custom check
O
oasis-cloud 已提交
40 41 42 43 44 45

:::demo
```tsx
import  React from "react";
import {  Tabbar, TabbarItem } from '@nutui/nutui-react';

46 47
const App = () => (
  <Tabbar visible={2}>
48
    <TabbarItem tabTitle="first" icon="home" />
49 50
    <TabbarItem tabTitle="Classification" icon="category" />
    <TabbarItem tabTitle="Find" icon="find" />
51
    <TabbarItem tabTitle="cart" icon="cart" />
52
    <TabbarItem tabTitle="mine" icon="my" />
53 54
  </Tabbar>
);
O
oasis-cloud 已提交
55

56
export default App;
O
oasis-cloud 已提交
57 58
```
:::
59
### Logo Tips
O
oasis-cloud 已提交
60 61 62 63

:::demo
```tsx
import  React from "react";
64
import { Tabbar, TabbarItem } from '@nutui/nutui-react';
O
oasis-cloud 已提交
65

66 67
const App = () => (
  <Tabbar>
68
    <TabbarItem tabTitle="first" icon="home" num="11" />
69 70
    <TabbarItem tabTitle="Classification" icon="category" />
    <TabbarItem tabTitle="Find" icon="find" />
71
    <TabbarItem tabTitle="cart" icon="cart" num="110" />
72
    <TabbarItem tabTitle="mine" icon="my" />
73 74
  </Tabbar>
);
O
oasis-cloud 已提交
75

76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
export default App;
```
:::

### Red dot

:::demo
```tsx
import  React from "react";
import { Tabbar, TabbarItem } from '@nutui/nutui-react';

const App = () => (
  <Tabbar>
    <TabbarItem tabTitle="first" icon="home" dot />
    <TabbarItem tabTitle="Classification" icon="category" />
    <TabbarItem tabTitle="Find" icon="find" />
    <TabbarItem tabTitle="cart" icon="cart" dot />
    <TabbarItem tabTitle="mine" icon="my" />
  </Tabbar>
)

97
export default App;
O
oasis-cloud 已提交
98 99
```
:::
100
### custom color
O
oasis-cloud 已提交
101 102 103 104 105 106

:::demo
```tsx
import  React from "react";
import {  Tabbar, TabbarItem } from '@nutui/nutui-react';

107 108
const App = () => (
  <Tabbar unactiveColor="#7d7e80" activeColor="#1989fa">
109
    <TabbarItem tabTitle="first" icon="home" />
110 111
    <TabbarItem tabTitle="Classification" icon="category" />
    <TabbarItem tabTitle="Find" icon="find" />
112
    <TabbarItem tabTitle="cart" icon="cart" />
113
    <TabbarItem tabTitle="mine" icon="my" />
114 115
  </Tabbar>
);
O
oasis-cloud 已提交
116

117
export default App;
O
oasis-cloud 已提交
118 119
```
:::
120
### Tabbar with customizable number of icons
O
oasis-cloud 已提交
121 122 123 124 125 126

:::demo
```tsx
import  React from "react";
import {  Tabbar, TabbarItem } from '@nutui/nutui-react';

127 128
const App = () => (
  <Tabbar unactiveColor="#7d7e80" activeColor="#1989fa">
129
    <TabbarItem tabTitle="first" icon="home" />
130 131
    <TabbarItem tabTitle="Classification" icon="category" />
    <TabbarItem tabTitle="Find" icon="find" />
132 133
  </Tabbar>
);
O
oasis-cloud 已提交
134

135
export default App;
O
oasis-cloud 已提交
136 137
```
:::
138
### Fixed bottom, free to jump
O
oasis-cloud 已提交
139 140 141 142 143 144

:::demo
```tsx
import  React from "react";
import {  Tabbar, TabbarItem } from '@nutui/nutui-react';

145 146
const App = () => (
  <Tabbar bottom>
147
    <TabbarItem tabTitle="first" href="" icon="home" />
148 149
    <TabbarItem tabTitle="Classification" icon="category" />
    <TabbarItem tabTitle="Find" icon="find" />
150
    <TabbarItem tabTitle="cart" href="https://m.jd.com" icon="cart" />
151
    <TabbarItem tabTitle="mine" to="/" icon="my" />
152 153
  </Tabbar>
);
O
oasis-cloud 已提交
154

155
export default App;
O
oasis-cloud 已提交
156 157 158 159 160 161 162 163 164
```
:::        

## API

### Prop

### nut-tabbar

165
| Prop            | Description                | Type   | Default  |
O
oasis-cloud 已提交
166
|-----------------|--------------------|--------|---------|
167 168 169 170 171 172 173 174
| visible | The index value of the selected label   | Number | 0       |
| bottom          | Whether it is fixed at the bottom of the page | Boolean | false   |
| unactiveColor  | Icon inactive color   | String | #7d7e80 |
| activeColor    | icon active color     | String | #1989fa |
| size    | icon size     | String 、Boolean | 20 |
| safeAreaInsetBottom    | Whether to enable the full screen bottom safety zone adaptation of the iphone series     | Boolean | false |
| style    | component style     | React.CSSProperties | {} |
| clsssName    | component class name     | String | - |
O
oasis-cloud 已提交
175 176 177

### tabbar-item

178
| Prop      | Description                                      | Type   | Default |
O
oasis-cloud 已提交
179
|-----------|-------------------------------------------|--------|--------|
180 181 182
| tabTitle | the title of the tab                              | String | --     |
| icon      | [icon name](#/icon) or image link displayed on the tab page | String | --     |
| href      | Jump link of tab page; if `to` exists at the same time, it takes precedence over to   | String | --     |
183
| to       | 	The route object of the tab, equal to React Router's [to Prop](https://v5.reactrouter.com/web/api/Link/to-string) Prop | any | --     |
184
| num       | The numerical corner mark in the upper right corner of the tab, if it exceeds 99, it will be 99+     | Number | --     |
185 186
| classPrefix      | 自Custom icon class name prefix for using custom icons   | String | 'nutui-iconfont'     |
| dot      | Whether to display the little red dot in the upper right corner of the icon   | Boolean | false     |
O
oasis-cloud 已提交
187 188 189 190


### Event

191
| Event   | Description               | callback parameter           |
O
oasis-cloud 已提交
192
|------------|--------------------|--------------------|
193
| tabSwitch | Trigger an event when switching tabs | Clicked data and index value |