DevExtreme React - Customize the Appearance
The Button widget provides five predefined appearances controlled by the type option. The type can be "normal", "default", "back", "danger" or "success". Choose the proper type depending on the commands that the Button performs.
- import React from 'react';
- import { Button } from 'devextreme-react/button';
- class App extends React.Component {
- render() {
- return (
- <Button
- type="default"
- text="Delete"
- onClick={this.foo}
- />
- );
- }
- foo(e) {
- // ...
- }
- }
- export default App;
Apart from plain text, the Button can display an icon. DevExtreme provides built-in icons that change their appearance depending on the platform. Alternatively, you can use an external icon library or standalone icons. To specify the icon, set the icon option.
- import React from 'react';
- import { Button } from 'devextreme-react/button';
- class App extends React.Component {
- render() {
- return (
- <Button
- type="danger"
- text="Delete"
- icon="remove"
- onClick={this.foo}
- />
- );
- }
- foo(e) {
- // ...
- }
- }
- export default App;
If you need to define the Button content completely, implement a template for it using the template option as shown in the following example.
- import React from 'react';
- import { Button } from 'devextreme-react/button';
- class App extends React.PureComponent {
- render() {
- return (
- <Button
- text="Refresh"
- onClick={this.foo}
- render={(buttonData) =>
- <i style={{ color: 'green' }}>{buttonData.text}</i>
- }
- />
- );
- }
- foo(e) {
- // ...
- }
- }
- export default App;
See Also
If you have technical questions, please create a support ticket in the DevExpress Support Center.