File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <template >
2+ <div class =" filled-textfield" :class =" { focus: isFocus }" >
3+ <label :class =" { lifted: isFocus || !isEmpty }" >{{ props.label }}</label >
4+ <input
5+ @focus =" isFocus = true"
6+ @blur =" isFocus = false"
7+ type =" text"
8+ v-model =" value"
9+ />
10+ </div >
11+ </template >
12+
13+ <script setup lang="ts">
14+ import { computed , ref } from " vue" ;
15+
16+ const value = defineModel <string >({ required: true });
17+ const props = defineProps <{
18+ label: string ;
19+ }>();
20+ const isFocus = ref (false );
21+ const isEmpty = computed (() => value .value === " " );
22+ </script >
23+
24+ <style lang="scss">
25+ .filled-textfield {
26+ background-color : var (--s-color-surface-container-high );
27+ border-top-left-radius : 5px ;
28+ border-top-right-radius : 5px ;
29+ border-bottom : var (--s-color-outline ) solid 0.15em ;
30+ transition :
31+ background-color 0.2s ,
32+ border-bottom-color 0.2s ;
33+ padding : 1em 0.6em 0.3em 0.6em ;
34+ display : flex ;
35+ & .focus {
36+ background-color : var (--s-color-surface-container-highest );
37+ border-bottom-color : var (--s-color-primary );
38+ label {
39+ color : var (--s-color-primary );
40+ }
41+ }
42+ input {
43+ background-color : transparent ;
44+ border : none ;
45+ outline : none ;
46+ font-size : inherit ;
47+ font-family : inherit ;
48+ display : block ;
49+ width : 0 ;
50+ flex-grow : 1 ;
51+ padding : 0 ;
52+ line-height : 1.2 ;
53+ z-index : 1 ;
54+ }
55+ label {
56+ color : var (--s-color-outline );
57+ position : absolute ;
58+ line-height : 1.2 ;
59+ transition :
60+ transform 0.2s ,
61+ font-size 0.2s ;
62+ transform : translateY (-0.3em );
63+ }
64+ label .lifted {
65+ transform : translateY (-120% );
66+ font-size : 0.6em ;
67+ }
68+ }
69+ </style >
You can’t perform that action at this time.
0 commit comments