Import
import { DragHandle } from '@contentful/f36-components';// orimport { DragHandle } from '@contentful/f36-drag-handle';
Examples
The DragHandle can be styled based on the props you pass to it:
Variants
DragHandle has 2 different variants:
- Secondary - Default variant.
- Transparent - For having an unstyled DragHandle.
function DragHandleVariantsExample() { return ( <Stack> <DragHandle label="Drag handle" /> <DragHandle variant="transparent" label="Transparent drag handle" /> </Stack> ); }
States
function DragHandleStatesExample() { return ( <Stack> <DragHandle isActive label="Active drag handle" /> <DragHandle isFocused label="Focus drag handle" /> <DragHandle isHovered label="Hovered drag handle" /> </Stack> ); }
Card example
<AssetCard title="Title" withDragHandle> <Text>This is a card example with DragHandle</Text> </AssetCard>
Props (API reference)
Open in Storybook
Name | Type | Default |
|---|---|---|
| label required | string Label rendered in DragHandle - not visible on screen as its purpose is for screen readers only | |
| as | "button" "div" The element used for the root node | div |
| className | string CSS class to be appended to the root element | |
| isActive | false true Applies styling for when the component is actively being dragged by the user | |
| isFocused | false true Applies focus styling | |
| isHovered | false true Applies hover styling | |
| testId | string A [data-test-id] attribute used for testing purposes | |
| type | string Set type button for div element | |
| variant | "secondary" "transparent" Determines style variation | secondary |
Accessibility
- You should pass a relevant label to DragHandle for screen readers, the label is not rendered.