New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@govuk-react/top-nav

Package Overview
Dependencies
Maintainers
5
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@govuk-react/top-nav

Styled top navigation header with numerous constituent parts input as props.

  • 0.9.0
  • npm
  • Socket score

Version published
Weekly downloads
4K
increased by8.71%
Maintainers
5
Weekly downloads
 
Created
Source

TopNav

Import

  import TopNav from '@govuk-react/top-nav';

Usage

TopNav with logo, service title and navigation items

import { SearchBox, TopNav } from 'govuk-react';
import CrownIcon from '@govuk-react/icon-crown';

const link = 'https://example.com?=1';

const Company = (
  <TopNav.Anchor href={link} target="new">
    <TopNav.IconTitle icon={<CrownIcon width="36" height="32" />}>GOV.UK</TopNav.IconTitle>
  </TopNav.Anchor>
);

const ServiceTitle = (
  <TopNav.NavLink href={link} target="new">
    Service Title
  </TopNav.NavLink>
);

const Search = (
  <SearchBox>
    <SearchBox.Input placeholder="Search GOV.UK" />
    <SearchBox.Button />
  </SearchBox>
);

<TopNav company={Company} serviceTitle={ServiceTitle} search={Search} active={0}>
  <TopNav.NavLink href="https://example.com?q=catdog" target="new">Navigation item #1</TopNav.NavLink>
  <TopNav.NavLink href="https://example.com?q=dogcat" target="new">Navigation item #2</TopNav.NavLink>
</TopNav>

With React Router

import { BrowserRouter, Link } from 'react-router-dom';
import { TopNav } from 'govuk-react';
import CrownIcon from '@govuk-react/icon-crown';

const reactRouterLink = '/section';
const CompanyLink = (
  <TopNav.Anchor as={Link} to={reactRouterLink}>
    <TopNav.IconTitle icon={<CrownIcon width="36" height="32" />}>GOV.UK</TopNav.IconTitle>
  </TopNav.Anchor>
);

const ServiceTitleLink = (
  <TopNav.NavLink as={Link} to={reactRouterLink}>
    Service Title
  </TopNav.NavLink>
);

<BrowserRouter>
  <TopNav company={CompanyLink} serviceTitle={ServiceTitleLink} />
</BrowserRouter>

References:

  • http://alphagov.github.io/govuk_template/example-proposition-menu.html
  • https://design-system.service.gov.uk/components/header/

TODO:

  • TODO: this component is a work in progress and needs to more closely match existing examples
  • TODO: is TopNav the right name? What's it called in other GDS styles/patterns?
  • TODO: (The name Header is ambiguous)
  • TODO: #205 Use context api and/or render props for active navigation items
  • TODO: Vertical alignment here needs some work, perhaps should be its own component
  • TODO: Icon should be lined up with font baseline, e.g. vertical-align: baseline

Properties

PropRequiredDefaultTypeDescription
bgColorBLACKstringTop nav background color
childrenundefinednodeList Navigation items with anchor tags e.g. NavAnchor components
colorWHITEstringTop nav text color
company<IconTitle icon={<CrownIcon width="36" height="32" />}>GOV.UK</IconTitle>nodeCompany component e.g. GOV UK
defaultOpenfalseboolIs the mobile navigation open by default?
searchfalsenodeSearch component
serviceTitleundefinednodeService title component e.g. Food Standards Authority

FAQs

Package last updated on 30 May 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc