doc.en-US.md 5.6 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

```ts
10
// react
O
oasis-cloud 已提交
11
import { Tabbar, TabbarItem } from '@nutui/nutui-react';
12 13
// taro
import { Tabbar, TabbarItem } from '@nutui/nutui-react-taro';
O
oasis-cloud 已提交
14 15
```

16
## code demo
O
oasis-cloud 已提交
17

18
### Basic usage
O
oasis-cloud 已提交
19 20 21 22 23 24

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

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

39
export default App;
O
oasis-cloud 已提交
40 41
```
:::
42
### custom check
O
oasis-cloud 已提交
43 44 45 46 47 48

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

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

59
export default App;
O
oasis-cloud 已提交
60 61
```
:::
62
### Logo Tips
O
oasis-cloud 已提交
63 64 65 66

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

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

79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
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>
)

100
export default App;
O
oasis-cloud 已提交
101 102
```
:::
103
### custom color
O
oasis-cloud 已提交
104 105 106 107 108 109

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

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

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

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

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

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

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

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

158
export default App;
O
oasis-cloud 已提交
159 160 161 162 163 164 165 166 167
```
:::        

## API

### Prop

### nut-tabbar

168
| Prop            | Description                | Type   | Default  |
O
oasis-cloud 已提交
169
|-----------------|--------------------|--------|---------|
170 171 172 173 174 175 176 177
| 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 已提交
178 179 180

### tabbar-item

181 182 183 184 185 186 187 188 189 190
| Prop                      | Description                                      | Type   | Default |
|---------------------------|-------------------------------------------|--------|--------|
| 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;   | String | --     |
| to`v1.4.0(Abandon)`              | 	The route object of the tab, equal to React Router's [to Prop](https://v5.reactrouter.com/web/api/Link/to-string) Prop | any | --     |
| num                       | The numerical corner mark in the upper right corner of the tab, if it exceeds 99, it will be 99+     | Number | --     |
| iconClassPrefix`v1.2.1`   | Custom icon class name prefix, used to use custom icons        | String                  | `nut-icon` |
| iconFontClassName`v1.2.1` | Basic class name of custom icon font        | String                  | `nutui-iconfont` |
| dot                       | Whether to display the little red dot in the upper right corner of the icon   | Boolean | false     |
O
oasis-cloud 已提交
191 192 193 194


### Event

195 196 197
| Event               | Description               | callback parameter           |
|---------------------|--------------------|--------------------|
| onSwitch`v1.3.8`    | Trigger an event when switching tabs | Clicked data and index value |