yarn add @workday/canvas-kit-labs-react
Sources
GitHubStorybookInstall
yarn add @workday/canvas-kit-labs-react
Use an Expandable Container when there is a lot of information to be shown on a page, but some details can initially be hidden from view.
Be cautious of hiding critical information or burdening the user with an extra click if they are likely to read all the content. There is a chance that content hidden within the collapsed state will not be read or immediately noticed by users.
For a basic expandable container with a chevron icon before the title, placeExpandable.Icon
before
Expandable.Title
as children of Expandable.Target
and pass the iconPosition
prop to
Expandable.Icon
with a value of start
. Expandable.Icon
will use a right chevron icon when
collapsed and a down chevron icon when expanded.
Content
For an expandable container with a chevron icon after the title, place Expandable.Title
before
Expandable.Icon
as children of Expandable.Target
and pass the iconPosition
prop to
Expandable.Icon
with a value of end
. Expandable.Icon
will use a down chevron icon when
collapsed and an up chevron icon when expanded.
Content
To include an avatar image, Expandable.Avatar
should be placed between Expandable.Icon
and
Expandable.Title
. An iconPosition
prop with a value of either start
or end
should be passed
to Expandable.Icon
depending on whether the Expandable.Icon
is placed before or after
Expandable.Title
.
Content
Content
Expandable container has bidirectional support and should function as expected with RTL languages as long as the content direction is set in your Canvas theme.
Content
Content
The depth
prop passed to Expandable
allows you to adjust the visual elevation of a component
using our depth tokens.
This Expandable Container has a depth of 3.
Long titles will wrap to the next line and increase the height of the container.
Content
You can also have direct access to the model if
If you you need direct access to the model, you can hoist it with the useExpandableModel
hook. In
the example below, we're hoisting the models to expand and collapse all three containers at once.
This component highlights the most important details of a section and reveals more when a user taps or clicks on the header part of the container. Enabling users to hide and show information ensures the design remains focused and relevant to their expectations. Scanning through the most critical information first makes processing more efficient without compromising the ability to access additional information.
Titles should be short and concise, yet long enough to explain what the user would expect to see when the content is expanded. If titles must be long, make sure it doesn't wrap more than two lines.
Expandable
wraps an Expandable.Target
and an Expandable.Content
. By default, it provides a
DisclosureModel
for its subcomponents. Alternatively, a model may be passed in using the
hoisted model pattern.
Expandable
supports all props from thelayout component.
Props extend from div. Changing the as
prop will change the element interface.
Props extend from . If a model
is passed, props from ExpandableModel Config
are ignored.
children
ReactNode
The children of the Expandable
container. This should contain Expandable.Target
and
Expandable.Container
as
React.ElementType
Optional override of the default element used by the component. Any valid tag or Component. If you provided a Component, this component should forward the ref using React.forwardRef
and spread extra props to a root element.
Note: Not all elements make sense and some elements may cause accessibility issues. Change this value with care.
div
ref
React.Ref
<
R
=
div
>
Optional ref. If the component represents an element, this ref will be a reference to the real DOM element of the component. If as
is set to an element, it will be that element. If as
is a component, the reference will be to that component (or element if the component uses React.forwardRef
).
model
Optional model to pass to the component. This will override the default model created for the component. This can be useful if you want to access to the state and events of the model, or if you have nested components of the same type and you need to override the model provided by React Context.
elemPropsHook
(
model
:
,
elemProps
:
TProps
) =>
HTML Attributes
Optional hook that receives the model and all props to be applied to the element. If you use this, it is your responsibility to return props, merging as appropriate. For example, returning an empty object will disable all elemProps hooks associated with this component. This allows finer control over a component without creating a new one.
Expandable.Target
creates a heading and a button. The heading is a semantic heading to
describe the associated content. The button provides users the ability to toggle the
associated content.
As according to the W3 disclosure
specification, the button has
aria-expanded
and aria-controls
attributes set by default
This component should hold an Expandable.Icon
, an optional Expandable.Avatar
, and an
Expandable.Title
.
Expandable.Target
supports all props from thelayout component.
Props extend from button. Changing the as
prop will change the element interface.
children
ReactNode
Children of the Expandable.Target
. Should contain Target.Title
, an optional Target.Avatar
and Target.Icon
with an iconPosition
prop that takes a value of either start
or end
.
Target.Icon
with start
is meant to be placed before the Target.Title
and Target.Icon
end
should be placed after.
headingLevel
' h1 '
|
' h2 '
|
' h3 '
|
' h4 '
|
' h5 '
|
' h6 '
This specifies the semantic heading level that will wrap the Expandable.Target
's button. If not
defined, then nothing will wrap the button.
as
React.ElementType
Optional override of the default element used by the component. Any valid tag or Component. If you provided a Component, this component should forward the ref using React.forwardRef
and spread extra props to a root element.
Note: Not all elements make sense and some elements may cause accessibility issues. Change this value with care.
button
ref
React.Ref
<
R
=
button
>
Optional ref. If the component represents an element, this ref will be a reference to the real DOM element of the component. If as
is set to an element, it will be that element. If as
is a component, the reference will be to that component (or element if the component uses React.forwardRef
).
model
Optional model to pass to the component. This will override the default model created for the component. This can be useful if you want to access to the state and events of the model, or if you have nested components of the same type and you need to override the model provided by React Context.
elemPropsHook
(
model
:
,
elemProps
:
TProps
) =>
HTML Attributes
Optional hook that receives the model and all props to be applied to the element. If you use this, it is your responsibility to return props, merging as appropriate. For example, returning an empty object will disable all elemProps hooks associated with this component. This allows finer control over a component without creating a new one.
(
model
:
,
elemProps
:
{}
,
ref
:
React.Ref
) =>
{
aria-controls
:
string
;
aria-expanded
:
boolean
;
onClick
:
(
event
:
) =>
void
;
}
Expandable.Title
styles the target text that describes the content.
Expandable.Title
supports all props from thelayout component.
Props extend from div. Changing the as
prop will change the element interface.
children
ReactNode
Children of the Expandable.Title
. This should contain a string for the title
as
React.ElementType
Optional override of the default element used by the component. Any valid tag or Component. If you provided a Component, this component should forward the ref using React.forwardRef
and spread extra props to a root element.
Note: Not all elements make sense and some elements may cause accessibility issues. Change this value with care.
div
ref
React.Ref
<
R
=
div
>
Optional ref. If the component represents an element, this ref will be a reference to the real DOM element of the component. If as
is set to an element, it will be that element. If as
is a component, the reference will be to that component (or element if the component uses React.forwardRef
).
Expandable.Icon
creates an icon to visually indicate the state of the content. It takes an
iconPosition
prop to determine which chevron icon to use.
Expandable.Icon
supports all props from thelayout component.
Props extend from span. Changing the as
prop will change the element interface.
icon
Icon to display from @workday/canvas-accent-icons-web
iconPosition
Button icon positions can either be start
or end
.
If no value is provided, it defaults to start
.
' start '
fill
The fill color of the SystemIcon. This overrides color
.
color
The color of the SystemIcon. This defines accent
and fill
. color
may be overriden by accent
and fill
.
size
number
|
string
|
undefined
The size of the SystemIcon in px
.
styles
shouldMirror
boolean
If set to true
, transform the SVG's x-axis to mirror the graphic
false
background
The background color of the SystemIcon.
children
ReactNode
accent
The accent color of the SystemIcon. This overrides color
.
accentHover
The accent color of the SystemIcon on hover. This overrides colorHover
.
backgroundHover
The background color of the SystemIcon on hover.
colorHover
The hover color of the SystemIcon. This defines accentHover
and fillHover
. colorHover
may be overriden by accentHover
and fillHover
.
fillHover
The fill color of the SystemIcon on hover. This overrides colorHover
.
as
React.ElementType
Optional override of the default element used by the component. Any valid tag or Component. If you provided a Component, this component should forward the ref using React.forwardRef
and spread extra props to a root element.
Note: Not all elements make sense and some elements may cause accessibility issues. Change this value with care.
span
ref
React.Ref
<
R
=
span
>
Optional ref. If the component represents an element, this ref will be a reference to the real DOM element of the component. If as
is set to an element, it will be that element. If as
is a component, the reference will be to that component (or element if the component uses React.forwardRef
).
model
Optional model to pass to the component. This will override the default model created for the component. This can be useful if you want to access to the state and events of the model, or if you have nested components of the same type and you need to override the model provided by React Context.
elemPropsHook
(
model
:
,
elemProps
:
TProps
) =>
HTML Attributes
Optional hook that receives the model and all props to be applied to the element. If you use this, it is your responsibility to return props, merging as appropriate. For example, returning an empty object will disable all elemProps hooks associated with this component. This allows finer control over a component without creating a new one.
(
model
:
,
elemProps
:
{}
,
ref
:
React.Ref
) =>
{
visible
:
boolean
;
}
Expandable.Avatar
is an optional component that creates an Avatar
to display a decorative
image.
Props extend from button. Changing the as
prop will change the element interface.
variant
The variant of the Avatar default state. Accepts Light
or Dark
.
ref
Ref
<
>
size
|
number
The size of the Avatar.
objectFit
Property.ObjectFit
The object-fit CSS property sets how the content of a replaced element, such as an or , should be resized to fit its container. See object-fit. If your image is not a square, you can use this property to ensure the image is rendered properly.
altText
string
The alt text of the Avatar image. This prop is also used for the aria-label
url
string
The url of the Avatar image.
children
React.ReactNode
as
React.ElementType
Optional override of the default element used by the component. Any valid tag or Component. If you provided a Component, this component should forward the ref using React.forwardRef
and spread extra props to a root element.
Note: Not all elements make sense and some elements may cause accessibility issues. Change this value with care.
button
ref
React.Ref
<
R
=
button
>
Optional ref. If the component represents an element, this ref will be a reference to the real DOM element of the component. If as
is set to an element, it will be that element. If as
is a component, the reference will be to that component (or element if the component uses React.forwardRef
).
Expandable.Content
holds the content that will be conditionally expanded and collapsed. It
has an id
to ensure the Expandable.Target
properly set it to the aria-controls
attribute.
Expandable.Content
supports all props from thelayout component.
Props extend from div. Changing the as
prop will change the element interface.
children
ReactNode
The children of the Expandable.Content
whose visibility is controlled by the associated
Expandable.Target
as
React.ElementType
Optional override of the default element used by the component. Any valid tag or Component. If you provided a Component, this component should forward the ref using React.forwardRef
and spread extra props to a root element.
Note: Not all elements make sense and some elements may cause accessibility issues. Change this value with care.
div
ref
React.Ref
<
R
=
div
>
Optional ref. If the component represents an element, this ref will be a reference to the real DOM element of the component. If as
is set to an element, it will be that element. If as
is a component, the reference will be to that component (or element if the component uses React.forwardRef
).
model
Optional model to pass to the component. This will override the default model created for the component. This can be useful if you want to access to the state and events of the model, or if you have nested components of the same type and you need to override the model provided by React Context.
elemPropsHook
(
model
:
,
elemProps
:
TProps
) =>
HTML Attributes
Optional hook that receives the model and all props to be applied to the element. If you use this, it is your responsibility to return props, merging as appropriate. For example, returning an empty object will disable all elemProps hooks associated with this component. This allows finer control over a component without creating a new one.
(
model
:
,
elemProps
:
{}
,
ref
:
React.Ref
) =>
{
style
:
{
display
:
undefined
;
}
|
{
display
:
string
;
}
;
id
:
string
;
}
The ExpandableModel
extends the DisclosureModel
useExpandableModel
(
config
: ):
With high quality products and considerate service, we will work together with you to enhance your business and improve the efficiency. Please don't hesitate to contact us to get more details of 40ft expandable container house.