Navbar is a fixed area at the top of a screen that contains Page title and navigation elements.
There are following components included:
Navbar
NavbarBackLink
Name | Type | Default | Description |
---|---|---|---|
bgClassName | string | Additional class to add on Navbar's "background" element | |
centerTitle | boolean | undefined | Makes centered navbar title. If not specified then it set it to center in iOS theme |
colors | object | Object with Tailwind CSS colors classes | |
colors.bgIos | string | 'bg-ios-light-surface-2 dark:bg-ios-dark-surface-2' | |
colors.bgMaterial | string | 'bg-md-light-surface-2 dark:bg-md-dark-surface-2' | |
colors.textIos | string | 'text-black dark:text-white' | |
colors.textMaterial | string | 'text-md-light-on-surface dark:text-md-dark-on-surface' | |
component | string | 'div' | Component's HTML Element |
fontSizeIos | string | 'text-[17px]' | Tailwind CSS class for font size in iOS theme |
fontSizeMaterial | string | 'text-[16px]' | Tailwind CSS class for font size in Material theme |
innerClassName | string | Additional class to add on Navbar's "inner" element | |
large | boolean | false | Renders large-sized navbar with extra row for large-sized title which becomes usual size on scroll |
left | ReactNode | Content of the Navbar's "left" area | |
leftClassName | string | Additional class to add on Navbar's "left" element | |
medium | boolean | false | Renders medium-sized navbar with extra row for medium-sized title which becomes usual size on scroll |
outline | boolean | undefined | Renders outer hairlines (borders). If not specified, will be enabled for iOS theme |
right | ReactNode | Content of the Navbar's "right" area | |
rightClassName | string | Additional class to add on Navbar's "right" element | |
scrollEl | any | undefined | Element required for correct "collapse" functionality for medium/large/transparent Navbar. If not specified, it will use Navbar's parent element |
subnavbar | ReactNode | Content of the Navbar's "subnavbar" area | |
subnavbarClassName | string | Additional class to add on Navbar's "subnavbar" element | |
subtitle | ReactNode | Content of the Navbar's "subtitle" area | |
subtitleClassName | string | Additional class to add on Navbar's "subtitle" element | |
title | ReactNode | Content of the Navbar's "title" area | |
titleClassName | string | Additional class to add on Navbar's "title" element | |
titleFontSizeIos | string | 'text-[17px]' | Tailwind CSS class for navbar title font size in iOS theme |
titleFontSizeMaterial | string | 'text-[22px]' | Tailwind CSS class for navbar title font size in Material theme |
titleLargeFontSizeIos | string | 'text-[34px]' | Tailwind CSS class for large-sized navbar title font size in iOS theme |
titleLargeFontSizeMaterial | string | 'text-[28px]' | Tailwind CSS class for large-sized navbar title font size in Material theme |
titleMediumFontSizeIos | string | 'text-[24px]' | Tailwind CSS class for medium-sized navbar title font size in iOS theme |
titleMediumFontSizeMaterial | string | 'text-[24px]' | Tailwind CSS class for medium-sized navbar title font size in Material theme |
translucent | boolean | true | Makes Navbar background translucent (with |
transparent | boolean | false | Renders transparent navbar which becomes opaque on scroll |
NavbarBackLink
should be placed in Navbar's "left" area:
<Navbar
left={
<NavbarBackLink text="Back" onClick={() => history.back()} />
}
title="My App"
/>
Name | Type | Default | Description |
---|---|---|---|
component | string | 'a' | Component's HTML Element |
showText | boolean | 'auto' | 'auto' | Defines whether to show the link text. When 'auto', it hides link text for Material theme |
text | ReactNode | 'Back' | Text content of the back link |
onClick | function(e) | Link click handler |
import React, { useState } from 'react';import {Page,Navbar,NavbarBackLink,Link,Block,BlockTitle,BlockHeader,List,ListItem,Radio,Toggle,} from 'konsta/react';export default function NavbarPage() {const [size, setSize] = useState('Default');const [isTransparent, setIsTransparent] = useState(false);return (<Page><Navbartitle="Navbar"subtitle="Subtitle"className="top-0 sticky"medium={size === 'Medium'}large={size === 'Large'}transparent={isTransparent}right={<Link navbar>Right</Link>}/><div className="relative"><Block strong inset><p>Navbar is a fixed area at the top of a screen that contains Pagetitle and navigation elements.</p></Block><BlockTitle>Size</BlockTitle><BlockHeader>Medium and Large will collapse to usual size on page scroll</BlockHeader><List strong inset>{['Default', 'Medium', 'Large'].map((v) => (<ListItemkey={v}labeltitle={v}after={<Radiocomponent="div"value={v}checked={size === v}onChange={() => setSize(v)}/>}/>))}</List><BlockTitle>Transparent</BlockTitle><BlockHeader>When navbar is transparent, its title and background will becomevisible on page scroll</BlockHeader><List strong inset><ListItemlabeltitle="Transparent"after={<Togglecomponent="div"checked={isTransparent === true}onChange={() => setIsTransparent(!isTransparent)}/>}/></List><Block strong inset className="space-y-4"><p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Iustotempore ratione unde accusantium distinctio nulla quia numquam earumodio, optio, nisi rem deserunt. Molestiae delectus, ut assumendanumquam magni enim.</p><p>Architecto molestias cum dolor dolorem provident consequunturincidunt sunt fugiat tenetur odio, recusandae placeat rem veniam.Voluptates, repellendus odit, magni nesciunt, optio laborumasperiores repudiandae consectetur suscipit ab cupiditate eum.</p><p>Aliquam, iste accusamus deleniti temporibus exercitationem nequeperferendis optio, blanditiis quisquam molestias perspiciatis cumqueharum tenetur veniam. Dolorum fugit doloribus est, deserunt,eligendi, quaerat quidem itaque tempore laborum non illum?</p><p>Rerum magni sunt quis veniam, dolor ratione saepe ducimus temporevoluptatum porro quod commodi? Aperiam laudantium deleniti totamdolorum qui accusantium iste saepe facere optio, soluta maximemollitia deserunt cumque.</p><p>Iusto tempore quis provident, saepe illum ex ipsum cupiditateexplicabo ratione unde facere nemo delectus harum, blanditiis eiussit asperiores nam. Aut cupiditate est tempore officia, perspiciatisesse asperiores repudiandae?</p><p>Consequuntur itaque harum eos vero, reiciendis dolorum iure nonearum molestias tenetur sint enim, maxime recusandae ad perferendisrepudiandae! Sit, quos exercitationem beatae numquam laborum nobisnatus. Obcaecati, ea inventore.</p><p>Fugit culpa labore sapiente excepturi reiciendis, nulla, nihil nequeut veritatis quis quibusdam dolorum? Voluptatibus animi officiaperspiciatis doloremque cum voluptatem, quia ratione modi vero,consequatur ipsum, praesentium quibusdam amet?</p><p>Laudantium nihil sint nam placeat, nemo rerum ipsam explicabo iustodolores molestiae expedita eos consequuntur ut architectoconsequatur soluta ad maiores voluptatem tenetur in velit. Minimaquia molestiae nobis voluptatibus.</p><p>Expedita soluta quia inventore et placeat id exercitationem quisquameligendi est eius sapiente quo, cum nesciunt mollitia, sit veniamducimus tempora culpa adipisci commodi in autem nihil voluptatemcorporis? Perspiciatis.</p><p>Molestias, est? Eligendi vero distinctio voluptatem cumque idvoluptatibus, officia minima repellendus sit illo tempora laboreprovident? Eum tenetur consectetur quae, in facilis autem ipsamdoloribus voluptate vitae suscipit nobis.</p><p>Obcaecati optio iste hic, soluta minus ullam, perferendis pariaturnon possimus autem nostrum libero sapiente. Corporis quo cum iustoexercitationem velit. Non beatae eveniet asperiores ipsaconsequuntur temporibus sapiente earum!</p><p>Temporibus, omnis. Excepturi dolorum expedita laudantium quasi quodid adipisci, esse, nam atque in, incidunt ex ab distinctiorepellendus beatae voluptatem alias odit illum quis. Illo numquamvoluptatibus error voluptatum!</p></Block></div></Page>);}
import React from 'react';import {Page,Navbar,NavbarBackLink,Block,Segmented,SegmentedButton,} from 'konsta/react';export default function SubnavbarPage() {return (<Page><Navbartitle="Subnavbar"subnavbar={<Segmented strong><SegmentedButton small strong active>Button</SegmentedButton><SegmentedButton small strong>Button</SegmentedButton><SegmentedButton small strong>Button</SegmentedButton></Segmented>}/><div className="relative"><Block strongIos outlineIos><p>Subnavbar is useful when you need to put any additional elementsinto Navbar, like Tab Links or Search Bar. It also remains visiblewhen Navbar hidden.</p></Block></div></Page>);}