Tags
Getting Started
Keep a look out on this space. Constantly adding more recipes over the next few months.
Give this repo a star, it will help out greatly!
- Vue Horizontal is required, and you need to install it .
- Recipes follow the design language defined in the design principle .
- You should be able to extract the code snippet and use it as a single file component.
- If you are consistently recycling a design pattern, you should abstract your SFC.
- It might look different on your website due various parent CSS rules. Tailwind is used under the hood with normalizing, that might be different from your default settings.
Recipes are designed:
- For the responsive web, using default breakpoints .
- For mobile first design,
peeking navigation
will be used on the mobile.
Assumption is made that you have a padding of 24px on the left and right on the mobile viewport.
The 24px is then removed and added into the
<vue-horizontal>
as scroll padding. - For broad usage pattern, you should take it and edit it your needs.
Why is it so complex? Why is it not shipped together with vue-horizontal?
- You control how to structure your content with HTML
- You control how it looks with CSS
- To give you greater control of your website and thus your code, vue-horizontal is merely a small component to horizontally align your content while fixing all the nasty quirks related to horizontal control (nav/scroll/touch). It also contains a few methods and event emitter that are optimized to make your life easier. It doesn't dictate how you structure your HTML or style your CSS. This responsive design logic is merely a skeleton of logic that is merely useful in that context. And every recipe may requires a different set of logic.
Full width
Zoom: 50% | 100% →
import=recipes/tags/recipes-tags-full.vue padding=0 zoom
<template>
<main>
<vue-horizontal class="horizontal" :displacement="0.5" :button-between="false">
<template v-slot:btn-prev>
<svg class="btn-left" viewBox="0 0 24 24">
<path d="m9.8 12 5 5a1 1 0 1 1-1.4 1.4l-5.7-5.7a1 1 0 0 1 0-1.4l5.7-5.7a1 1 0 0 1 1.4 1.4l-5 5z"/>
</svg>
</template>
<template v-slot:btn-next>
<svg class="btn-right" viewBox="0 0 24 24">
<path d="m14.3 12.1-5-5a1 1 0 0 1 1.4-1.4l5.7 5.7a1 1 0 0 1 0 1.4l-5.7 5.7a1 1 0 0 1-1.4-1.4l5-5z"/>
</svg>
</template>
<div class="item" v-for="tag in tags" :key="tag.name">
<button class="tag">
{{ tag.name }}
</button>
</div>
</vue-horizontal>
<article>
<h3>Full Width Tags</h3>
<p>You want to show a bunch of text but don't want it to take up too much real estate.
So you decided to overflow horizontally. Vue Horizontal to the rescue!</p>
</article>
</main>
</template>
<script>
export default {
data() {
return {
tags: [
{name: 'VueJS'}, {name: 'Nuxt'}, {name: 'Gridsome'}, {name: 'VuePress'},
{name: 'ReactJS'}, {name: 'Next'}, {name: 'Gatsby'}, {name: 'Node.js'},
{name: 'Typescript'}, {name: 'Javascript'}, {name: 'Webpack'}, {name: 'HTML'}, {name: 'CSS'},
{name: 'Java'}, {name: 'Spring Boot'}, {name: 'Spring Framework'}, {name: 'Gradle'}, {name: 'Maven'},
{name: 'Python'}, {name: 'Flutter'}, {name: 'Terraform'},
{name: 'CircleCI'}, {name: 'IntelliJ'},
{name: 'GitHub'},
]
}
}
}
</script>
<style scoped>
.tag {
font-weight: 600;
font-size: 15px;
color: #777;
border: 1px solid #e2e8f0;
border-radius: 3px;
line-height: 1;
padding: 8px 24px;
margin-right: 16px;
}
.btn-left, .btn-right {
padding: 6px;
height: 100%;
}
.btn-left {
background: linear-gradient(to left, #ffffff00 0, #fff 50%, #fff);
}
.btn-right {
background: linear-gradient(to right, #ffffff00 0, #fff 50%, #fff);
}
main {
padding: 24px;
}
@media (min-width: 768px) {
main {
padding: 48px;
}
}
article {
margin-top: 24px;
}
</style>
Tight space
Zoom: 50% | 100% →
import=recipes/tags/recipes-tags-tight.vue padding=0 zoom
<template>
<main>
<div class="search">
<div class="field">
<label>
<input placeholder="Search">
</label>
</div>
<vue-horizontal class="horizontal" :displacement="0.9" :button-between="false" snap="center">
<template v-slot:btn-prev>
<svg class="btn-left" viewBox="0 0 24 24">
<path d="m9.8 12 5 5a1 1 0 1 1-1.4 1.4l-5.7-5.7a1 1 0 0 1 0-1.4l5.7-5.7a1 1 0 0 1 1.4 1.4l-5 5z"/>
</svg>
</template>
<template v-slot:btn-next>
<svg class="btn-right" viewBox="0 0 24 24">
<path d="m14.3 12.1-5-5a1 1 0 0 1 1.4-1.4l5.7 5.7a1 1 0 0 1 0 1.4l-5.7 5.7a1 1 0 0 1-1.4-1.4l5-5z"/>
</svg>
</template>
<div class="item" v-for="tag in tags" :key="tag.name">
<button class="tag">
{{ tag.name }}
</button>
</div>
</vue-horizontal>
</div>
<article>
<h3>Tight Spacing Tags</h3>
<p>You want to put something on the left or right of the horizontal space.</p>
</article>
</main>
</template>
<script>
export default {
data() {
return {
tags: [
{name: 'VueJS'}, {name: 'Nuxt'}, {name: 'Gridsome'}, {name: 'VuePress'},
{name: 'ReactJS'}, {name: 'Next'}, {name: 'Gatsby'}, {name: 'Node.js'},
{name: 'Typescript'}, {name: 'Javascript'}, {name: 'Webpack'}, {name: 'HTML'}, {name: 'CSS'},
{name: 'Java'}, {name: 'Spring Boot'}, {name: 'Spring Framework'}, {name: 'Gradle'}, {name: 'Maven'},
{name: 'Python'}, {name: 'Flutter'}, {name: 'Terraform'},
{name: 'CircleCI'}, {name: 'IntelliJ'},
{name: 'GitHub'},
]
}
}
}
</script>
<style scoped>
.search {
display: flex;
}
input {
font-weight: 600;
font-size: 17px;
padding: 4px 16px;
border: 1px solid #e2e8f0;
border-radius: 3px;
width: 100%;
}
.field {
padding-right: 24px;
flex-shrink: 0;
width: 65%;
}
.horizontal {
flex-shrink: 1;
flex-grow: 1;
width: 20%;
}
.tag {
font-weight: 600;
font-size: 15px;
color: #777;
border: 1px solid #e2e8f0;
border-radius: 3px;
line-height: 1;
height: 100%;
padding-left: 18px;
padding-right: 18px;
margin-right: 16px;
}
.btn-left, .btn-right {
padding: 8px 2px;
height: 100%;
}
.btn-left {
background: linear-gradient(to left, #ffffff00 0, #fff 80%, #fff);
}
.btn-right {
background: linear-gradient(to right, #ffffff00 0, #fff 80%, #fff);
}
main {
padding: 24px;
}
@media (min-width: 768px) {
main {
padding: 48px;
}
}
article {
margin-top: 24px;
}
</style>