All Projects β†’ marco-streng β†’ styled-off-canvas

marco-streng / styled-off-canvas

Licence: MIT License
A simple off canvas menu built with styled-components πŸ’…

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to styled-off-canvas

Mmenu Js
The best javascript plugin for app look-alike on- and off-canvas menus with sliding submenus for your website and webapp.
Stars: ✭ 2,535 (+4055.74%)
Mutual labels:  navigation, off-canvas
Handycontrols
Contains some simple and commonly used WPF controls based on HandyControl
Stars: ✭ 347 (+468.85%)
Mutual labels:  styled-components, navigation
React Site Nav
A kick ass site menu powered by styled components inspired by Stripe.
Stars: ✭ 155 (+154.1%)
Mutual labels:  styled-components, navigation
styled-components-docs-zh
πŸ’… styled-components δΈ­ζ–‡ζ–‡ζ‘£ηΏ»θ―‘ πŸ‡ζŒη»­ζ–½ε·₯δΈ­
Stars: ✭ 160 (+162.3%)
Mutual labels:  styled-components
kaptain
πŸ‘¨β€βœˆοΈ multi-module navigation on Android has never been so easier!
Stars: ✭ 24 (-60.66%)
Mutual labels:  navigation
ml-stack-nav
Customizable, responsive, accessible, easy-to-use multi-level stack navigation menu with slide effect.
Stars: ✭ 20 (-67.21%)
Mutual labels:  navigation
Helm
A graph-based SwiftUI router
Stars: ✭ 64 (+4.92%)
Mutual labels:  navigation
Codist
A visual studio extension which enhances syntax highlighting, quick info (tooltip), navigation bar, scrollbar, display quality and brings smart tool bar to code editor.
Stars: ✭ 134 (+119.67%)
Mutual labels:  navigation
codemill.vmfirstnav
Xamarin.Forms ViewModel First Navigation Library
Stars: ✭ 22 (-63.93%)
Mutual labels:  navigation
styled-units
You might want to try https://github.com/donavon/styled-shortcuts instead
Stars: ✭ 14 (-77.05%)
Mutual labels:  styled-components
Fluent-Design
Microsoft's Fluent Design with pure HTML/CSS/JS
Stars: ✭ 36 (-40.98%)
Mutual labels:  navigation
medly-components
🧩 Medly components provides numerous themable react components, each with multiple varitaions of sizes, colors, position etc.
Stars: ✭ 66 (+8.2%)
Mutual labels:  styled-components
twitch-stocks
A web platform that allows you to invest in Twitch streamers with imaginary points.
Stars: ✭ 17 (-72.13%)
Mutual labels:  styled-components
nextjs-with-material-ui-and-styled-components
Next.js with material-ui and styled-components
Stars: ✭ 100 (+63.93%)
Mutual labels:  styled-components
netflix landing-page
The Netflix.com landing page built via React 16 and Styled-Components. Build deployed via Surge.sh for preview.
Stars: ✭ 39 (-36.07%)
Mutual labels:  styled-components
react-universal-starter
React@16, react-router@4, redux and webpack@4 starter project
Stars: ✭ 44 (-27.87%)
Mutual labels:  styled-components
styled-native-polished
Styled Components helpers for React Native
Stars: ✭ 21 (-65.57%)
Mutual labels:  styled-components
styled-svg
A styled-components generator for SVG files to use in react
Stars: ✭ 37 (-39.34%)
Mutual labels:  styled-components
minesweeper
πŸ’£Minesweeper game written with React
Stars: ✭ 18 (-70.49%)
Mutual labels:  styled-components
react-component-library-lerna
Build your own React component library managed with lerna, presented with storybook and published in private npm registry.
Stars: ✭ 55 (-9.84%)
Mutual labels:  styled-components

styled-off-canvas

πŸ’… styled-off-canvas

A simple off canvas menu built with styled-components

Node CI build status JavaScript Standard Style Built with Styled Components

Description

styled-off-canvas is a customizable off-canvas menu built with React and styled-components

Demo

A demo can be found here: Demo

Installation

yarn install styled-off-canvas
# or via npm
npm install styled-off-canvas

Implementation

For more flexibility you will keep the menu state (open or closed) in your application. The example below shows a very simple implementation.

Components

styled-off-canvas comes with three components: <StyledOffCanvas />, <Menu /> and <Overlay />.

<StyledOffCanvas /> is a wrapping component which provides all settings/properties.

<Menu /> is the off-canvas menu itself. You can pass anything you want as children (e.g. styled list of react-router links)

<Overlay /> is an optional component which renders a semi-transparent layer above your app content.

Example

import React, { useState } from 'react'
import { StyledOffCanvas, Menu, Overlay } from 'styled-off-canvas'

const App = () => {
  const [isOpen, setIsOpen] = useState(false)

  return (
    <StyledOffCanvas
      isOpen={isOpen}
      onClose={() => setIsOpen(false)}
    >

      <button onClick={() => setIsOpen(!isOpen)}>Toggle menu</button>

      <Menu>
        <ul>
          <li>
            <a onClick={() => setIsOpen(false)}>close</a>
          </li>
          <li>
            <a href='/about'>About</a>
          </li>
          <li>
            <a href='/contact'>Contact</a>
          </li>
        </ul>
      </Menu>

      <Overlay />

      <div>this is some nice content!</div>
    </StyledOffCanvas>
  )
}

export default App

Properties

<StyledOffCanvas /> component

  • isOpen = false: if the menu should be visible or not
  • menuBackground = '#fff': background color of the menu
  • menuDuration = '500ms': duration of the css transition of the menu
  • onClose: callback function if menu closes (e.g. by click on the overlay)
  • closeOnEsc = true: if the menu should close on esc keydown
  • overlayBackground = '#000': background color of the overlay
  • overlayDuration = '500ms': duration of the open/close animation of the overlay
  • overlayOpacity = 0.2: css opacity of the overlay
  • position = 'right': position of the menu (left or right)
  • width = '300px': maximum width of the menu

Also <Menu /> and <Overlay /> can additionally be customized with styled-components

// example

<Menu css={{ border: `1px solid ${theme.menu.borderColor}` }}>...</Menu>

Local development

Install dependencies and start the development server

yarn
yarn dev

or via npm

npm install
npm run dev

Open localhost:8080 in your browser.

Resources

License

Copyright (c) 2021-present Marco Streng. See LICENSE for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].