Skip to content

Commit

Permalink
fix as suggested
Browse files Browse the repository at this point in the history
  • Loading branch information
siriwatknp committed Dec 16, 2024
1 parent 161d96c commit 805bd6a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as React from 'react';
import Box from '@mui/material/Box';
import { outlinedInputClasses } from '@mui/material/OutlinedInput';
import { filledInputClasses } from '@mui/material/FilledInput';
import { inputBaseClasses } from '@mui/material/InputBase';
import TextField from '@mui/material/TextField';
Expand All @@ -24,13 +23,8 @@ export default function InputSuffixShrink() {
<InputAdornment
position="end"
sx={{
alignSelf: 'flex-end',
opacity: 0,
marginBottom: '5px',
pointerEvents: 'none',
[`.${outlinedInputClasses.root} &`]: {
marginBottom: '16px',
},
[`[data-shrink=true] ~ .${inputBaseClasses.root} > &`]: {
opacity: 1,
},
Expand All @@ -54,10 +48,9 @@ export default function InputSuffixShrink() {
sx={{
alignSelf: 'flex-end',
opacity: 0,
marginBottom: '5px',
pointerEvents: 'none',
[`.${filledInputClasses.root} &`]: {
marginBottom: '8px',
marginBottom: '7.5px',
},
[`[data-shrink=true] ~ .${inputBaseClasses.root} > &`]: {
opacity: 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as React from 'react';
import Box from '@mui/material/Box';
import { outlinedInputClasses } from '@mui/material/OutlinedInput';
import { filledInputClasses } from '@mui/material/FilledInput';
import { inputBaseClasses } from '@mui/material/InputBase';
import TextField from '@mui/material/TextField';
Expand All @@ -24,13 +23,8 @@ export default function InputSuffixShrink() {
<InputAdornment
position="end"
sx={{
alignSelf: 'flex-end',
opacity: 0,
marginBottom: '5px',
pointerEvents: 'none',
[`.${outlinedInputClasses.root} &`]: {
marginBottom: '16px',
},
[`[data-shrink=true] ~ .${inputBaseClasses.root} > &`]: {
opacity: 1,
},
Expand All @@ -54,10 +48,9 @@ export default function InputSuffixShrink() {
sx={{
alignSelf: 'flex-end',
opacity: 0,
marginBottom: '5px',
pointerEvents: 'none',
[`.${filledInputClasses.root} &`]: {
marginBottom: '8px',
marginBottom: '7.5px',
},
[`[data-shrink=true] ~ .${inputBaseClasses.root} > &`]: {
opacity: 1,
Expand Down
5 changes: 3 additions & 2 deletions docs/data/material/components/text-fields/text-fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ For instance, you can use an icon button to hide or reveal the password.

{{"demo": "InputAdornments.js"}}

### Visible on shrink
#### Customizing adornments

By customizing the suffix's opacity based on the shrink attribute, the suffix is visible when the label is shrunk.
You can apply custom styles to adornments, and trigger changes to one based on attributes from another.
For example, the demo below uses the label's `[data-shrink=true]` attribute to make the suffix visible (via opacity) when the label is in its shrunken state.

{{"demo": "InputSuffixShrink.js"}}

Expand Down

0 comments on commit 805bd6a

Please # to comment.