Move Chevron Icon to the Right in SidebarNavigationDisclosure #4247
-
Hello,I'm working with the By default, the chevron appears on the left side, but for my design, I need it to be positioned on the right side. Screenshot:Current Code:<SidebarNavigationDisclosure>
<SidebarNavigationDisclosureHeadingWrapper>
<SidebarNavigationDisclosureHeading icon={<ProductContactCenterTeamsIcon decorative />} selected>
Drivers
</SidebarNavigationDisclosureHeading>
</SidebarNavigationDisclosureHeadingWrapper>
<SidebarNavigationDisclosureContent>
<SidebarNavigationItem
href="/drivers/applications"
onClick={(e) => { e.preventDefault(); navigate('/drivers/applications'); }}
selected={window.location.pathname === '/drivers/applications'}
>
Driver Applications
</SidebarNavigationItem>
</SidebarNavigationDisclosureContent>
</SidebarNavigationDisclosure> What I Tried:I attempted to manually place the chevron on the right side using
Attempted Code:const [isOpen, setIsOpen] = useState(false);
const handleToggle = () => {
setIsOpen(prevState => !prevState);
};
<SidebarNavigationDisclosure>
<SidebarNavigationDisclosureHeadingWrapper>
<Box display="flex" justifyContent="space-between" alignItems="center">
<SidebarNavigationDisclosureHeading icon={<ProductContactCenterTeamsIcon decorative />} selected>
Drivers
</SidebarNavigationDisclosureHeading>
<ChevronDownIcon
decorative={false}
title="Toggle"
onClick={handleToggle}
style={{
transform: isOpen ? 'rotate(180deg)' : 'rotate(0)',
transition: 'transform 0.3s ease',
color: 'white',
}}
/>
</Box>
</SidebarNavigationDisclosureHeadingWrapper>
<SidebarNavigationDisclosureContent isOpen={isOpen}>
<SidebarNavigationItem href="/drivers/applications" selected={window.location.pathname === '/drivers/applications'}>
Driver Applications
</SidebarNavigationItem>
</SidebarNavigationDisclosureContent>
</SidebarNavigationDisclosure> Question:Is there a built-in way in Any guidance would be greatly appreciated. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Disclaimer: This is a very experimental bot using OpenAI's GPT-4. The answers may not be correct, a human will review the answer and update it if necessary. Sorry, I don't know how to help with that. I did do a search though, and I managed to find these other Discussions that might be similar or related to your question. Give them a read to see if they answer your question. If they do, head back here and update this discussion and mark it as answered, pointing others to the related discussion:
|
Beta Was this translation helpful? Give feedback.
-
The Here's a recommended approach:
Here's an example implementation: import { useSidebarNavigationDisclosureState } from '@twilio-paste/core/sidebar';
import { ChevronDisclosureIcon } from '@twilio-paste/icons/esm/ChevronDisclosureIcon';
const SidebarNavigationDisclosureExample = () => {
const disclosure = useSidebarNavigationDisclosureState();
return (
<SidebarNavigationDisclosure state={disclosure}>
<SidebarNavigationDisclosureHeadingWrapper>
<Box display="flex" justifyContent="space-between" alignItems="center">
<SidebarNavigationDisclosureHeading icon={<ProductContactCenterTeamsIcon decorative />} selected>
Drivers
</SidebarNavigationDisclosureHeading>
<Box
as="span"
display="flex"
color="colorTextIconInverse"
height="sizeIcon20"
width="sizeIcon20"
transition="transform 150ms ease"
transform={disclosure.visible ? 'rotate(90deg)' : 'rotate(0deg)'}
onClick={disclosure.toggle}
>
<ChevronDisclosureIcon color="inherit" decorative size="sizeIcon20" />
</Box>
</Box>
</SidebarNavigationDisclosureHeadingWrapper>
<SidebarNavigationDisclosureContent>
<SidebarNavigationItem
href="/drivers/applications"
selected={window.location.pathname === '/drivers/applications'}
>
Driver Applications
</SidebarNavigationItem>
</SidebarNavigationDisclosureContent>
</SidebarNavigationDisclosure>
);
}; This approach uses the To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other |
Beta Was this translation helpful? Give feedback.
-
Hi @Clinton-dev 👋 this is not currently supported for the component. Is this a product of Twilio? You can achieve something similar though by using our CustomizationProvider to target the specific header elements. Here is a CodeSandbox for how this works and code snippet below. The issue with this is it would also change the decorative icon and text positions. If you removed icons you could get it to look good if you added <CustomizationProvider
elements={{
SIDEBAR_NAVIGATION_DISCLOSURE_HEADING: {
direction: "rtl",
},
}}
> |
Beta Was this translation helpful? Give feedback.
Hi @Clinton-dev 👋 this is not currently supported for the component. Is this a product of Twilio?
You can achieve something similar though by using our CustomizationProvider to target the specific header elements. Here is a CodeSandbox for how this works and code snippet below. The issue with this is it would also change the decorative icon and text positions. If you removed icons you could get it to look good if you added
justifyContent: "space-between"
to the customization. provider.