@spark-web/utils v5.0.0
title: Utilities
isExperimentalPackage: true
š§ ā Under construction
forwardRefWithAs
A best effort attempt to provide strongly typed polymorphic components that (as the name suggests) forwards the ref onto the underlying element.
Internally this is used for our layout primitives (Box, Columns,
Container, Hidden, Inline, Row and Stack), our link components
(Link, ButtonLink and TextLink), our typographic components (Heading and
Text) and finally VisuallyHidden.
export const PolymorphicComponent = forwardRefWithAs<
'div',
PolymorphicComponentProps
>(({ as: Tag = 'div', ...consumerProps }, forwardedRef) => {
return (
<Tag
{...consumerProps}
ref={forwardedRef}
// Custom props go here
/>
);
});12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
10 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
10 months ago
12 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
12 months ago
12 months ago
12 months ago
12 months ago
10 months ago
11 months ago
11 months ago
1 year ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago