doc.en-US.md 5.5 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';
O
oasis-cloud 已提交
12

O
oasis-cloud 已提交
13 14
```

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

## API

### Prop

### nut-tabbar

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

### tabbar-item

180 181 182 183 184 185 186 187 188 189
| 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 已提交
190 191 192 193


### Event

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