AdminAction is a component used by Admin action extensions to configure a primary and secondary action and title. Use of this component is required in order to use Admin action extensions.
import React from 'react';
import {
reactExtension,
AdminAction,
Button,
Text,
} from '@shopify/ui-extensions-react/admin';
function App() {
return (
<AdminAction
title="My App Action"
primaryAction={
<Button onPress={() => {}}>Action</Button>
}
secondaryAction={
<Button onPress={() => {}}>
Secondary
</Button>
}
>
<Text>Modal content</Text>
</AdminAction>
);
}
export default reactExtension(
'Playground',
() => <App />,
);
import {extension, AdminAction, Button} from '@shopify/ui-extensions/admin';
export default extension('Playground', (root) => {
const primaryAction = root.createFragment();
const secondaryAction = root.createFragment();
primaryAction.appendChild(
root.createComponent(Button, {onPress: () => {}}, 'Action')
);
secondaryAction.appendChild(
root.createComponent(Button, {onPress: () => {}}, 'Secondary')
);
const adminAction = root.createComponent(AdminAction, {
title: 'My App Action',
primaryAction,
secondaryAction,
}, 'Modal content');
root.appendChild(adminAction);
root.mount();
});
Sets the loading state of the action modal
Sets the Primary action button of the container. This component must be a button component.
Sets the Secondary action button of the container. This component must be a button component.
Sets the title of the Action container. If not provided, the name of the extension will be used. Titles longer than 40 characters will be truncated.