Bruno Jesus
Bruno Jesus

Reputation: 11

Change the size of header input item on clarity design

I'm using an header bar from the clarity.design examples, I tinkered with it trying to make the search input occupy 100% of the center of the header bar, but I'm unable to do it.

The code:

<clr-header class="header-6">
    <div class="branding">
      <a [routerLink]="['/']" routerLinkActive="router-link-active"  class="nav-link">
        <span class="title">Project Clarity</span>
      </a>
    </div>

    <form class="search" (ngSubmit)="onSearchSubmit(f)" #f="ngForm">
      <label for="search_input"></label>
      <input id="search_input" name="search_input" type="text" placeholder=" Search for keywords or paste link..." ngModel required>
    </form>

    <div class="header-actions">
      <div class="header-nav" [clr-nav-level]="1">
        <a class="nav-link nav-text">
          My menu
        </a>
      </div>

      <clr-dropdown>
        <button class="nav-icon" clrDropdownTrigger>
          <clr-icon shape="user"></clr-icon>
          <clr-icon shape="caret down"></clr-icon>
        </button>
        <clr-dropdown-menu *clrIfOpen clrPosition="bottom-right">
          <a clrDropdownItem>Preferences</a>
          <a clrDropdownItem>Log out</a>
        </clr-dropdown-menu>
      </clr-dropdown>
    </div>
  </clr-header>

This is how it looks like, I want the header to use all the remaining width. bar screenshot

Thanks.

Upvotes: 1

Views: 1164

Answers (2)

hippeelee
hippeelee

Reputation: 1808

The header is using flex box for layout.

Here is a POC stackblitz that uses the below css to override the default search styles.

CSS

.search {
  border: 1px solid deeppink;
  flex: 1 1 auto;
  max-width: none;
}

.search > label {
  flex: 1 1 auto;
  max-width: 90%;
}

.search > label > input {
  width: 100%;
}

It should give you a starting point to tweak for your apps visual style. You may also need to address the responsive use case.

Upvotes: 1

acarlstein
acarlstein

Reputation: 1838

The solution of your problem is CSS.

I gave you an example below that shows you where you can start from.

Let me know if this helps you out.

/* First, make your elements float to the left or right */
.header-6 div
, .header-6 form {
  float: left;
}

div.header-actions{
  float: right;
}

/* Then give them some space */
div.branding
, form.search
, div.header-actions {
  padding-left: 20px;
  padding-right: 20px;;
}

 /* The rest is using FontAwesome and CSS to add the icons and the other stuff */
<clr-header class="header-6">
    <div class="branding">
      <a [routerLink]="['/']" routerLinkActive="router-link-active"  class="nav-link">
        <span class="title">Project Clarity</span>
      </a>
    </div>

    <form class="search" (ngSubmit)="onSearchSubmit(f)" #f="ngForm">
      <label for="search_input"></label>
      <input id="search_input" name="search_input" type="text" placeholder=" Search for keywords or paste link..." ngModel required>
    </form>

    <div class="header-actions">
      <div class="header-nav" [clr-nav-level]="1">
        <a class="nav-link nav-text">
          My menu
        </a>
      </div>

      <clr-dropdown>
        <button class="nav-icon" clrDropdownTrigger>
          <clr-icon shape="user"></clr-icon>
          <clr-icon shape="caret down"></clr-icon>
        </button>
        <clr-dropdown-menu *clrIfOpen clrPosition="bottom-right">
          <a clrDropdownItem>Preferences</a>
          <a clrDropdownItem>Log out</a>
        </clr-dropdown-menu>
      </clr-dropdown>
    </div>
  </clr-header>

Upvotes: 0

Related Questions