Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support space-between in form field #5747

Closed
Misiu opened this issue Mar 26, 2020 · 3 comments · Fixed by #5759
Closed

Support space-between in form field #5747

Misiu opened this issue Mar 26, 2020 · 3 comments · Fixed by #5759

Comments

@Misiu
Copy link

Misiu commented Mar 26, 2020

Feature Request

I'm trying to create this type of UI:
image
with web components, but unfortunately it isn't easy doable.
I was suggested to use formfield but this gives me this:
image

The label is on the other side and there is no space between.

I got a suggestion from @asyncLiz (in material-components/material-web#999) to create this FR and ask to add mdc-form-field--space-between that would allow easy creating such UI.

This type of UI is presented at official material.io site: https://material.io/components/selection-controls/#switches so I think there should be first-class support for it.

Proposed solution

Alternatives considered

Additional context

My main goal is to have support for this in https://github.com/material-components/material-components-web-components, but I think if this will be addressed here then the next step is adding support in web components.

@asyncLiz
Copy link
Contributor

Proposed solution would be to add the following CSS:

.mdc-form-field--space-between {
  justify-content: space-between;
}

@asyncLiz
Copy link
Contributor

@Misiu we'll need to prioritize resources for this, but it should be a relatively easy feature to add if you want to take a shot at a pull request.

@Misiu
Copy link
Author

Misiu commented Mar 27, 2020

@asyncLiz something like this: https://jsfiddle.net/Misiu/quzgcsev/25/ ??
image

I never did PR to this repo, but I can try if the results are ok with you 🙂

copybara-service bot pushed a commit that referenced this issue Mar 31, 2020
This PR adds `mdc-form-field--space-between` class.
fixes: #5747
This allows easily creating this layout:
![image](https://user-images.githubusercontent.com/1741838/77768710-23904a80-7043-11ea-9c44-8febdc8e0430.png)

https://jsfiddle.net/Misiu/quzgcsev/25/
Sample code:

```
<div class="mdc-form-field mdc-form-field--space-between" id="form1">
  <div class="mdc-switch" id="switch1">
    <div class="mdc-switch__track"></div>
    <div class="mdc-switch__thumb-underlay">
      <div class="mdc-switch__thumb"></div>
      <input type="checkbox" id="basic-switch1" class="mdc-switch__native-control" role="switch" aria-checked="false">
    </div>
  </div>
  <label for="basic-switch1">off/on</label>
</div>
```

I've added support for `mdc-form-field--align-end`, but I'm not sure how support for RTL languages should look.

Also, this is my first PR in this repo, so sorry for any mistakes.

PiperOrigin-RevId: 303416506
copybara-service bot pushed a commit that referenced this issue Apr 1, 2020
This PR adds `mdc-form-field--space-between` class.
fixes: #5747
This allows easily creating this layout:
![image](https://user-images.githubusercontent.com/1741838/77768710-23904a80-7043-11ea-9c44-8febdc8e0430.png)

https://jsfiddle.net/Misiu/quzgcsev/25/
Sample code:

```
<div class="mdc-form-field mdc-form-field--space-between" id="form1">
  <div class="mdc-switch" id="switch1">
    <div class="mdc-switch__track"></div>
    <div class="mdc-switch__thumb-underlay">
      <div class="mdc-switch__thumb"></div>
      <input type="checkbox" id="basic-switch1" class="mdc-switch__native-control" role="switch" aria-checked="false">
    </div>
  </div>
  <label for="basic-switch1">off/on</label>
</div>
```

I've added support for `mdc-form-field--align-end`, but I'm not sure how support for RTL languages should look.

Also, this is my first PR in this repo, so sorry for any mistakes.

PiperOrigin-RevId: 303416506
aforemny pushed a commit to aforemny/material-components-web that referenced this issue Mar 5, 2021
This PR adds `mdc-form-field--space-between` class.
fixes: material-components#5747
This allows easily creating this layout:
![image](https://user-images.githubusercontent.com/1741838/77768710-23904a80-7043-11ea-9c44-8febdc8e0430.png)

https://jsfiddle.net/Misiu/quzgcsev/25/
Sample code:

```
<div class="mdc-form-field mdc-form-field--space-between" id="form1">
  <div class="mdc-switch" id="switch1">
    <div class="mdc-switch__track"></div>
    <div class="mdc-switch__thumb-underlay">
      <div class="mdc-switch__thumb"></div>
      <input type="checkbox" id="basic-switch1" class="mdc-switch__native-control" role="switch" aria-checked="false">
    </div>
  </div>
  <label for="basic-switch1">off/on</label>
</div>
```

I've added support for `mdc-form-field--align-end`, but I'm not sure how support for RTL languages should look.

Also, this is my first PR in this repo, so sorry for any mistakes.

PiperOrigin-RevId: 304204642
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment