@devadeboye/material-component-library-v2 v8.1.0
material-component-library-v2
Material component library is a library of custom react components implemented according to material design 3 specification using react, typescript and tailwindcss.
Table of Contents
Button
Common button component for UI actions.
Parameters
propsObject The properties for the button.props.heightstring Tailwind height command to configure the height of the button. (optional, default"h-10")props.borderRadiusstring The border radius of the button. Default is ButtonBorderEnum.full. (optional, defaultButtonBorderEnum.full)props.variantstring? The variant of the button. This could be filled, outlined etc.props.classNamestring? Additional classes for the button.props.namestring? The name or label of the button.props.iconstring? The icon to be displayed on the button.props.widthstring The width of the button. (optional, default"w-full")props.onClickfunction? The function to be executed on button click.props.disabledboolean Indicates whether the button is disabled. (optional, defaultfalse)
Returns JSX.Element The button component.
Fab
Floating action buttons (FABs) help people take primary actions
Note: Label is only shown in extended FAB
Type: React.FC\
Parameters
propsObject The properties for the button.props.iconstring The icon to display on the button.props.fabTypestring The type of FAB to render (optional, defaultFabTypeEnum.FAB)props.buttonColourstring Colour of the button (optional, default"")props.buttonTextColourstring Colour of text on the button (optional, default"")props.buttonStateObject Object to manage the state of the FABprops.onClickFunction? Function to call when the FAB is clicked (optional, default()=>{})props.label(optional, default"Extended FAB")props.buttonProps...any
Returns JSX.Element The FAB component.
SegmentedButton
Segmented buttons help people select options, switch views, or sort elements
To learn more about material design segmented button visit https://m3.material.io/components/segmented-buttons/specs
Parameters
propsObject The properties for the Segmented button.props.classNamestring? Additional classes for the button. (optional, default"")props.numberOfSegmentsstring The number of segments the button should contain. The number of buttons shown depends on the numberOfSegments passed in.* when numberOfSegments is two, only first and fifth buttons are shown.- when numberOfSegments is three, only first, second and fifth buttons are shown.
- when numberOfSegments is four, only first, second, third and fifth buttons are shown.
- when numberOfSegments is five, all buttons are shown.You need to keep this in mind when passing callbacks for each buttons (optional, default
SegmentedButtonNumberOfSegmentsEnum.two)
props.edgeStylestring This tells how the corner of the button is going to be styled. This could be round or fully round.* when you pass in round, the edge will be slightly rounded. This uses the "lg" class in tailwindcss- when you pass in fully round, the edge will be fully rounded. This uses the "full" class in tailwindcss (optional, default
SegmentedButtonStyleEnum.round)
- when you pass in fully round, the edge will be fully rounded. This uses the "full" class in tailwindcss (optional, default
props.activeButtonColourstring The colour the active button/segment should have; defaults to the material secondary container colour token. (optional, default"bg-light-secondaryContainer")props.buttonsConfigurationObject? Configuration for each segment in the button.props.buttonStateprops.buttonStateUpdater
Returns JSX.Element The segmented button component.
List
Lists are continuous, vertical indexes of text and images
Parameters
propsObject The properties for the Segmented button.props.classNamestring? Additional classes for the listprops.itemsArray\ is the array of items to display in the listprops.items.id(string | number) The id for each list item. This is necessary incases where you need to reference each item in the list uniquelyprops.items.headlinestring This is the main content in the list itemprops.items.nullstring [overline] - An overline drawing attention to the list itemprops.items.nullstring [supportingText] - Text explaining the list itemprops.items.metaGenericType Additional information about the list item
props.leadingstring Icon to display at the beginging of each list item. Its optional and it defaults to empty stringprops.trailingstring Icon to display at the end of each list item. Its optional and it defaults to empty stringprops.dividerboolean This indicates if the list is going to be seperated by dividersprops.dividerStyleObject Additional information about the list itemprops.dividerStyle.typestring this describe the type of divider; values can be full-width, inset, middle-inset.* when dividerStyle type is fullWidth, the divider takes the whole width of the list itemprops.dividerStyle.marginAfterDividerboolean this determines if there is going to be a margin after the divider or not
props.conditionstring? This describe the type of list item. it can be one-line, two-lines, three-lines (optional, defaultListItemConditionEnum.oneLine)props.onListItemClickfunction? This is an optional function to call on each list item when clicked. The list item component is going to pass the id of the item on this component to your click event handler. This can be used to handle things like deleting list item. (optional, default()=>{})
Returns JSX.Element The List component.
Modal
Modal
Parameters
propsObject The properties for the Modal.props.onHideOverlayfunction this is a callback function that contains logic to hide the overlay on clickprops.children(ReactNode | Array\) this are the elements to display in the modalprops.overlayRootstring location in the dom where the modal should be displayed... its a stringprops.backdropColourstring? optional tailwindcss class to be used to style the backdrop colour. It should be passed with its opacity value e.g bg-dark-scrim/75. it defaults to black at 75% opacity (optional, default"bg-dark-scrim/75")props.maxHeightstring? maximum height of the modal (optional, default"max-h-[70%] sm:max-h-[60%]")props.topPositionstring? the position of the modal on the top side of the screen (optional, default"top-[32vh] sm:top-[30vh]")props.leftPositionstring? the position of the modal on the left side of the screen (optional, default"left-0 sm:left-[30%]")props.width(optional, default"w-full sm:w-2/5")
TextField
This is a textfield component styled according to google's material design specification
Parameters
propsObject The properties for the TextField.props.leadingstring? This is an optional icon to be displayed at the start of the textfieldprops.trailingstring? This is an optional icon to be displayed at the end of the textfieldprops.supportingTextstring? This is an optional text that further explain the textfieldprops.labelstring This specify the label of the textfieldprops.contentTypestring The type of content the textfield is holding. This could be button, checkbox, date, color etc.props.classNamestring? A field to pass in additional tailwind class to still the textfieldprops.onBlurfunction? Callback function to call when the textfield lose focusprops.onChangefunction? Callback function to call when the textfield content changesprops.stateObject An object consisting a react state and the dispatch function to set the state.props.widthstring The width of the textfield. This accept only tailwind classes (optional, default"w-full")props.styleprops.inputRef
Returns JSX.Element The Textfield component.
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago