Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@react-md/form
Advanced tools
Create material design form elements with a lot of customization. This package exports the following form components:
Form
- A simple wrapper for a <form>
element that just prevents default
submit behavior for convenienceFieldset
- A simple wrapper for the <fieldset>
element that removes some
of the default styles and integrates a <legend>
that be be conditionally
rendered for screen readers onlyLabel
- A <label>
element that is also built-in to the majority of the
other form controlsFileInput
- A wrapper for <input type="file" />
that gains the
<Button />
stylesNativeSelect
- A wrapper for the native <select>
element that updates the
select to have the same styles as a TextField
. You are unable to style the
<option>
s due to styling restrictionsSelect
- A component that allows you to create an accessible listbox that
behaves like a native <select>
element but also allows for additional
styling from the @react-md/list
packageTextField
- A styled <input type="text" />
that supports a few themes as
well as other input types. Note:Password
- A wrapper for the TextField
to render as a type="password"
that has built-in functionality to temporarily show the password to the user
with an inline visibility toggle buttonTextArea
- A styled <texxtarea>
that has a few themes and can animate the
height as the user typesCheckbox
- A wrapper for an <input type="checkbox" />
Radio
- A wrapper for an <input type="radio" />
Switch
- A wrapper for an <input type="checkbox" />
that looks like a
toggleable switchAsyncSwitch
- A wrapper for the Switch
component that has built-in support
for displaying a circular progress in the Switch
during asynchronous actionsFormMessage
- A component that can be used to display accessible help and
error messages along with other form components that will be read out to
screen readers.This package also exports the following helper components and hooks:
useChecked
- A simple hook that controls the checked state for the
Checkbox
or Switch
componentsuseIndeterminateChecked
- A hook that can be used for checkbox groups with
an indeterminate stateuseChoice
- A simple hook that can be used to control the state of a radio
group or select components while type-casting the value for Typescript users.
Note: This does not validate the value stringuseSelectState
- A hook for Typescript users that type-casts the value.
Note: This does not validate the value stringFloatingLabel
- A <label>
element that can be used to animate a label out
of an <input type="text" />
or <textarea>
if additional customization is
requiredListbox
- A component that implements the
listbox widget specifications
with keyboard search and movement built-in.Option
- A wrapper for the SimpleListItem
from @react-md/list
that
allows for additional styling and accessibility requirements for an "option"
roleTextFieldContainer
- A styled <div>
that is used for render the different
themesTextFieldAddon
- A component that might not be used much externally, but it
can be used to gain the styles for the addons for a TextArea
and TextField
(built-in)InputToggle
- A component that is used to render either a "checkbox"
or
"radio"
elementToggleCotainer
- A helper component that is used to wrap either a
"checkbox"
or "radio"
for additional stylesnpm install --save @react-md/form
It is also recommended to install the other packages if you have not done so:
npm install --save @react-md/theme \
@react-md/typography \
You should check out the full documentation for live examples and more customization information, but an example usage is shown below.
It is recommended to check out the documentation site for a better example, but here's a simple one that you should really not copy:
import React, { useState } from "react";
import { render } from "react-dom";
import { Button } from "@react-md/button";
import { Form, TextField, Password, useChecked } from "@react-md/form";
import { EmailSVGIcon, PasswordSVGIcon } from "@react-md/material-icons";
const App = () => {
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const [rememberMe, setRememberMe] = useChecked(false);
const [errors, setErrors] = useState<string[]>([]);
const handleSubmit = async () => {
const response = await fetch("/login", {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
body: JSON.stringify({ email, password }),
});
const json = await response.json();
if (json.errors) {
setErrors(errors);
} else {
// do something
}
};
return (
<Form onSubmit={handleSubmit}>
<FormMessage id="errors" role="alert" error disableWrap>
{errors.length && (
<ul>
{errors.map((error) => (
<li key={error}>{error}</li>
))}
</ul>
)}
</FormMessage>
<TextField
aria-describedby="errors"
id="email"
label="Email"
type="email"
name="email"
value={email}
onChange={(event) => setEmail(event.currentTarget.value)}
required
leftAddon={<EmailSVGIcon />}
/>
<Password
aria-describedby="errors"
id="password"
label="Password"
name="password"
value={password}
onChange={(event) => setPassword(event.currentTarget.value)}
required
leftAddon={<PasswordSVGIcon />}
/>
<Checkbox
id="remember-me"
name="rememberMe"
label="Remember me?"
checked={rememberMe}
onChange={setRememberMe}
/>
<Button id="submit" type="submit">
Log in
</Button>
</Form>
);
};
render(<App />, document.getElementById("root"));
3.0.0 (2021-08-13)
This release should be relatively simple for most consumers of this library since the main breaking change is dropping support for node-sass
and requiring sass
since node sass has been deprecated as well as removing deprecated variables, hooks, and components.
Most users should be able to run the following commands to upgrade to v3.0.0:
npm update react-md
npm uninstall node-sass
npm install sass
Or with yarn
yarn add react-md
yarn remove node-sass
yarn add sass
In addition, there is now partial support for the new Sass module system with the react-md
package which also simplifies the import usage and has a slight build performance improvement for large projects.
To start using the new module system, update all the @import
statements as shown below:
-@import '~@react-md/theme/dist/mixins';
-@import '~@react-md/utils/dist/mixins';
-// other react-md imports
+@use 'react-md' as *;
// No other changes required!
If you override variables within react-md
:
-@import '~@react-md/theme/dist/color-palette';
-$rmd-theme-light: false;
-$rmd-theme-primary: $rmd-purple-500;
-$rmd-theme-secondary: $rmd-pink-a-200;
-
-@import '~react-md/dist/styles';
+@use '@react-md/theme/dist/color-palette' as color;
+@use 'react-md' as * with (
+ $rmd-theme-light: false,
+ $rmd-theme-primary: color.$rmd-theme-purple-500,
+ $rmd-theme-secondary: color.$rmd-theme-pink-a-200,
+);
+
+@include react-md-utils;
Check out the updated customizing your theme documentation, #1214, or 958f34f for more in-depth examples.
$rmd-theme-dark-elevation
now defaults to true
instead of false
node-sass
is no longer supported and users must switch to sass
InteractionModeListener
since it was an alias for UserInteractionModeListener
ResizeObserver
component and useResizeObserverV1
implementationTooltipHoverModeConfig
component$rmd-card-dark-elevation-bordered-background-color
variableTooltipped
componentuseIndeterminateChecked
is now an object of optionssass
since it's deprecated (126fb5a)defaults
to true (b371337)sass
usage with: @use 'react-md';
(787bfb5)@use
(68e8c6b)react-md/dist/_everything.scss
(c7177e6)sassdoc
and variables to use everything.scss (a0f0699)sass
(5376be1)useIndeterminateChecked
(6b7871f)Tooltipped
component (6dca9b1)typedoc
API in navigation tree (c388ba6)@use
imports (958f34f)defaults
(b2269ff)sass
instead of node-sass (d8ddf51)react-md
(c0f25f7)FAQs
This package is for creating all the different form input types.
The npm package @react-md/form receives a total of 1,892 weekly downloads. As such, @react-md/form popularity was classified as popular.
We found that @react-md/form demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.