nuxt-breaky
![License](https://img.shields.io/npm/l/nuxt-breaky.svg?style=flat-square)
Show Tailwind CSS Breakpoints in Nuxtjs when using the tailwindcss-module
Intro
DEMO
breaky helps you create your responsive designs faster. It extends the awesome tailwindcss-module. breaky reads your defined breakpoints within your tailwind config and shows the currently active breakpoint based on your browser window width.
The plugin will only be loaded during development mode and does not interfere with your production build.
![Toggling between Dark and Light Mode Demo GIF of toggling dark mode](https://github.com/teamnovu/vue-breaky-core/raw/HEAD/./example/assets/img/toggle-dark-mode.gif)
Requirements
Make sure tailwindcss-module: ^1.4.0
(or higher) is installed.
Setup
Nuxt
- Add
nuxt-breaky
as a dev-dependency to your project
yarn add nuxt-breaky --dev
- Add
nuxt-breaky
to the buildModules
section of nuxt.config.js
NOTE: Use the modules
section if you are using Nuxt older than v2.9
. More Info
{
buildModules: [
'nuxt-breaky',
[
'nuxt-breaky',
{
enabled: true,
enableInProd: false,
colorScheme: 'auto',
position: 'bottomRight'
}
]
]
}
- Add
exposeConfig: true
to the tailwindcss
section of nuxt.config.js
{
tailwindcss: {
exposeConfig: true
}
}
NOTE: Please be aware this adds ~19.5KB (~3.5KB) to the client bundle size when you are in development mode. More Info
Vue
- Add
nuxt-breaky
as a dev-dependency to your project
yarn add nuxt-breaky --dev
- Add the following code to your
main.js
import resolveConfig from 'tailwindcss/resolveConfig'
import Breaky from 'nuxt-breaky/lib/plugin-vue'
Vue.use(Breaky, {
tailwindConfig: resolveConfig(require('./tailwind.config')),
enabled: true,
enableInProd: process.env.DEPLOY_ENV === 'GH_PAGES',
position: 'bottomRight',
colorScheme: 'auto',
})
NOTE: Please be aware this adds ~19.5KB (~3.5KB) to the bundle size when you are in development mode.
Usage
The breaky module automatically adds the breaky plugin when in development
mode.
No need to register or include it anywhere else.
Configuration
Nuxt
You can pass options to the breaky using both the module options and the Nuxt config way.
{
buildModules: {
['nuxt-breaky', { }]
},
breaky: {
}
}
Vue
Vue.use(Breaky, {
})
Available Options
Option | Type | Default | Options | Description |
---|
enabled | Boolean | true | true | false | Enable/Disable breaky |
enableInProd | Boolean | false | true | false | Enable breaky in production (overrides the enabled option; Please be aware this adds ~19.5KB (~3.5KB) to the client bundle size. More Info) |
colorScheme | String | auto | 'auto' | 'light' | 'dark' | Switch between different color schemes |
position | String | 'bottomRight' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | Breakys starting position |
Development
- Clone this repository
- Install dependencies using
yarn install
- Start development server using
yarn dev
Release
yarn release:patch
(minor
or major
)npm publish
License
MIT License
Copyright (c) teamnovu