2015-11-01 17:19:45 +03:00
|
|
|
# Snackbar
|
|
|
|
|
|
|
|
Snackbars provide lightweight feedback about an operation by showing a brief message at the bottom of the screen. Snackbars can contain an action.
|
|
|
|
|
|
|
|
<!-- example -->
|
|
|
|
```jsx
|
|
|
|
import { Button, Snackbar } from 'react-toolbox';
|
|
|
|
|
|
|
|
class SnackbarTest extends React.Component {
|
|
|
|
handleClick = () => {
|
|
|
|
this.refs.snackbar.show();
|
|
|
|
};
|
|
|
|
|
|
|
|
handleSnackbarClick = () => {
|
|
|
|
this.refs.snackbar.hide();
|
|
|
|
};
|
|
|
|
|
|
|
|
render () {
|
|
|
|
return (
|
|
|
|
<section>
|
2015-11-17 23:49:27 +03:00
|
|
|
<Button label='Show Snackbar' raised onClick={this.handleClick} />
|
2015-11-01 17:19:45 +03:00
|
|
|
<Snackbar
|
|
|
|
action='Nice'
|
|
|
|
label='A new developer started using React Toolbox'
|
|
|
|
onClick={this.handleSnackbarClick}
|
|
|
|
ref='snackbar'
|
|
|
|
type='accept'
|
|
|
|
/>
|
|
|
|
</section>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2016-05-30 07:59:44 +03:00
|
|
|
This component can be styled by context providing a theme with the key `RTSnackbar` through the theme provider.
|
|
|
|
|
2015-11-01 17:19:45 +03:00
|
|
|
## Properties
|
|
|
|
|
2016-04-07 04:24:31 +03:00
|
|
|
| Name | Type | Default | Description|
|
2015-11-01 17:19:45 +03:00
|
|
|
|:-----|:-----|:-----|:-----|
|
2016-04-07 04:24:31 +03:00
|
|
|
| `action` | `String` | | Label for the action component inside the Snackbar.|
|
|
|
|
| `active` | `Boolean` | `false` | If true, the snackbar will be active.|
|
2016-10-08 13:27:57 +03:00
|
|
|
| `children` | `String or Element` | `false` | Text or node to be displayed in the content as alternative to `label`.|
|
2016-04-07 04:24:31 +03:00
|
|
|
| `className` | `String` | `''` | Additional class name to provide custom styling.|
|
2016-10-08 13:27:57 +03:00
|
|
|
| `label` | `String or Element` | | Text to display in the content.|
|
2016-04-07 04:24:31 +03:00
|
|
|
| `onClick` | `Function` | | Callback function that will be called when the button action is clicked.|
|
|
|
|
| `onTimeout` | `Function` | | Callback function when finish the set timeout.|
|
|
|
|
| `timeout` | `Number` | | Amount of time in milliseconds after the Snackbar will be automatically hidden.|
|
|
|
|
| `type` | `String` | | Indicates the action type. Can be `accept`, `warning` or `cancel`|
|
2016-05-25 01:41:26 +03:00
|
|
|
|
2016-05-30 07:59:44 +03:00
|
|
|
## Theme
|
2016-05-25 01:41:26 +03:00
|
|
|
|
|
|
|
| Name | Description|
|
|
|
|
|:---------|:-----------|
|
|
|
|
| `accept` | Added to the root element in case it's accept type.|
|
|
|
|
| `active` | Added to the root element when its active.|
|
|
|
|
| `button` | Used for the button inside the component.|
|
|
|
|
| `cancel` | Added to the root element in case it's cancel type.|
|
|
|
|
| `label` | Used for the label element.|
|
2017-01-05 04:42:18 +03:00
|
|
|
| `portal` | Used for the portal container element.|
|
2016-05-25 01:41:26 +03:00
|
|
|
| `snackbar` | Used as the className for the root element of the component.|
|
|
|
|
| `warning` | Added to the root element in case it's warning type.|
|