React ActionSheet - Customize Item Appearance
For a minor customization of ActionSheet buttons, you can define specific fields in button data objects. For example, the following code generates three buttons, the first is not customized, the second is disabled, the type of the third button is danger.
- import React from 'react';
- import 'devextreme/dist/css/dx.light.css';
- import { ActionSheet } from 'devextreme-react/action-sheet';
- class App extends React.Component {
- constructor(props) {
- super(props);
- this.actionSheetData = [
- { text: "Reply" },
- { text: "Reply All", disabled: true },
- { text: "Delete", type: 'danger' }
- ];
- }
- render() {
- return (
- <ActionSheet
- dataSource={this.actionSheetData}
- />
- );
- }
- }
- export default App;
If you need a more flexible solution, define an itemTemplate.
App.js
styles.css
- import React from 'react';
- import 'devextreme/dist/css/dx.light.css';
- import { ActionSheet } from 'devextreme-react/action-sheet';
- class App extends React.Component {
- constructor(props) {
- super(props);
- this.state = { isActionSheetVisible: true };
- this.actionSheetData = [
- { text: "Reply" },
- { text: "Reply All" },
- { text: "Forward" },
- { text: "Delete" }
- ];
- this.renderActionSheetItem = (itemData) => {
- return (
- <div class="action-sheet-button">
- <a href="#">{itemData.text}</a>
- </div>
- );
- };
- }
- render() {
- return (
- <ActionSheet
- visible={this.state.isActionSheetVisible}
- dataSource={this.actionSheetData}
- itemRender={this.renderActionSheetItem}
- />
- );
- }
- }
- export default App;
- .action-sheet-button {
- margin: 5px;
- padding: 10px;
- border: 1px dotted #080;
- background-color: white;
- }
See Also
Feel free to share topic-related thoughts here.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
Thank you for the feedback!
If you have technical questions, please create a support ticket in the DevExpress Support Center.