Skip to content

Commit a182623

Browse files
committed
docs(CNavbar): add external content example
1 parent 93609dd commit a182623

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

packages/docs/content/4.0/components/navbar.mdx

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,6 +1278,60 @@ return (
12781278
)
12791279
```
12801280

1281+
### External content
1282+
1283+
Sometimes you want to use the collapse plugin to trigger a container element for content that structurally sits outside of the `<CNavbar>`.
1284+
1285+
export const ExternalContentExample = () => {
1286+
const [visible, setVisible] = useState(false)
1287+
return (
1288+
<>
1289+
<CCollapse id="navbarToggleExternalContent" visible={visible}>
1290+
<div className="bg-dark p-4">
1291+
<h5 className="text-white h4">Collapsed content</h5>
1292+
<span className="text-medium-emphasis-inverse">Toggleable via the navbar brand.</span>
1293+
</div>
1294+
</CCollapse>
1295+
<CNavbar colorScheme="dark" className="bg-dark">
1296+
<CContainer fluid>
1297+
<CNavbarToggler
1298+
aria-controls="navbarToggleExternalContent"
1299+
aria-label="Toggle navigation"
1300+
onClick={() => setVisible(!visible)}
1301+
/>
1302+
</CContainer>
1303+
</CNavbar>
1304+
</>
1305+
)
1306+
}
1307+
1308+
<Example>
1309+
<ExternalContentExample />
1310+
</Example>
1311+
1312+
```jsx
1313+
const [visible, setVisible] = useState(false)
1314+
return (
1315+
<>
1316+
<CCollapse id="navbarToggleExternalContent" visible={visible}>
1317+
<div className="bg-dark p-4">
1318+
<h5 className="text-white h4">Collapsed content</h5>
1319+
<span className="text-medium-emphasis-inverse">Toggleable via the navbar brand.</span>
1320+
</div>
1321+
</CCollapse>
1322+
<CNavbar colorScheme="dark" className="bg-dark">
1323+
<CContainer fluid>
1324+
<CNavbarToggler
1325+
aria-controls="navbarToggleExternalContent"
1326+
aria-label="Toggle navigation"
1327+
onClick={() => setVisible(!visible)}
1328+
/>
1329+
</CContainer>
1330+
</CNavbar>
1331+
</>
1332+
)
1333+
```
1334+
12811335
## API
12821336

12831337
### CNavbar

0 commit comments

Comments
 (0)