Material-ui: Where is the button[type="submit"]?

Created on 8 Jul 2016  路  11Comments  路  Source: mui-org/material-ui

I check the component http://www.material-ui.com/#/components/
I found button is base on span, so how do I get the effect of button[type="submit"] ?
Maybe span[type="submit"] can work in chrome, but other browser?

ButtonBase support

Most helpful comment

seems like <FlatButton type="submit" ... will just do the trick, but the documentation doesn't include this property.

All 11 comments

Button isn't based on span.
image

hi @nathanhere, I think @eromoe 's main question is how to use Component Button to achieve a functionality that a native HTML <button type="submit">submit</button> has, which normally just submit the current form without any script.

seems like <FlatButton type="submit" ... will just do the trick, but the documentation doesn't include this property.

@neekey It doesn't work with <IconButton /> though. :|

I agree, I think it would be nice to do <IconButton type='submit' />. As a workaround though, you can provide your own component to IconButton to render the button. I was able to get something similar to the following to work:

const SubmitButton = (props) => ( <button {...props} type='submit' />);

<IconButton component={SubmitButton} />

This should render the button with type=submit. The component property is documented on the ButtonBase API

@neekey I just saw that I may have been mistakenly mentioned in this thread (3 years later :D)

If you're like me that just skims around when reading the docs and didn't find a type prop in the IconButton docs . . . there is this message at the end of the Props list:

Any other properties supplied will be provided to the root element (ButtonBase).

ButtonBase accepts the type prop, so just add type=submit to the IconButton component like so: <IconButton type="submit">

Posting this here for anyone coming from Google.

Sorry, but I'm trying to add this attribute to a Button component and I'm getting a TypeScript error. I checked the ButtonBase API docs but I can't find any reference to the "type" attribute:

https://material-ui.com/api/button-base/

Seems like a pretty common use case so I'd find odd if it's not supported, unless I'm missing something.

@amypellegrini The reason type isn't documented for the ButtonBase is that we don't cover the native HTML attributes.

@oliviertassinari it would be great to use the material-ui Button styles, and being able to have button submit types and so on. Is there any plan to support that?

馃憢 Thanks for using Material-UI!

We use GitHub issues exclusively as a bug and feature requests tracker, however,
this issue appears to be a support request.

For support, please check out https://material-ui.com/getting-started/support/. Thanks!

If you have a question on StackOverflow, you are welcome to link to it here, it might help others.
If your issue is subsequently confirmed as a bug, and the report follows the issue template, it can be reopened.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chris-hinds picture chris-hinds  路  3Comments

ryanflorence picture ryanflorence  路  3Comments

ghost picture ghost  路  3Comments

mb-copart picture mb-copart  路  3Comments

finaiized picture finaiized  路  3Comments