Title: Setting Text Field Width?
Last modified: August 30, 2016

---

# Setting Text Field Width?

 *  Resolved [Dave Mackey](https://wordpress.org/support/users/davidshq/)
 * (@davidshq)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/setting-text-field-width/)
 * I’m not sure if I’m understanding field types correctly…
 * There is a text_small and a text_medium field type but no text_large field type?
 * And is there a way to adjust the width of the text_small and text_medium field
   types?
 * For example, could one do away with _small and _medium and just have text like
   so:
 *     ```
       $cmb->add_field( array(
        'name'    => 'Test Text',
        'desc'    => 'field description (optional)',
        'default' => 'standard value (optional)',
        'width' => '25%',
        'id'      => 'wiki_test_text',
        'type'    => 'text_'
        ) );
       ```
   
 * [https://wordpress.org/plugins/cmb2/](https://wordpress.org/plugins/cmb2/)

Viewing 9 replies - 1 through 9 (of 9 total)

 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [10 years, 8 months ago](https://wordpress.org/support/topic/setting-text-field-width/#post-6380092)
 * I wager the “text” field type would be the “large” equivalent. [https://github.com/WebDevStudios/CMB2/wiki/Field-Types](https://github.com/WebDevStudios/CMB2/wiki/Field-Types)
 * [https://cloudup.com/cg4uAUqPGTS](https://cloudup.com/cg4uAUqPGTS) from “text”
   to “text_small”
 * Should be able to hook in your own CSS and override if necessary. I’d recommend`
   admin_enqueue_script` [https://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts](https://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts)
   with a low priority or perhaps `admin_head`
 *  Plugin Author [Justin Sternberg](https://wordpress.org/support/users/jtsternberg/)
 * (@jtsternberg)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/setting-text-field-width/#post-6380122)
 * What you’re talking about can be accomplished via the `attributes` field property:
 *     ```
       $cmb->add_field( array(
       	'name'       => 'Test Text',
       	'desc'       => 'field description (optional)',
       	'default'    => 'standard value (optional)',
       	'id'         => 'wiki_test_text',
       	'type'       => 'text',
       	'attributes' => array(
       		'style' => 'width:25%;',
       	),
       ) );
       ```
   
 *  Thread Starter [Dave Mackey](https://wordpress.org/support/users/davidshq/)
 * (@davidshq)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/setting-text-field-width/#post-6380293)
 * Thanks Michael and Justin, this is very helpful!
 *  [srmahmud2](https://wordpress.org/support/users/srmahmud2/)
 * (@srmahmud2)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/setting-text-field-width/#post-6380420)
 * Hi there,
 * I am here having difficulty to load my custom css after the default cmb2-style.
   css
 *     ```
       <link rel='stylesheet' id='cmb2-override-css'  href='http://localhost/.../cmb2-style.css?ver=4.3.1' type='text/css' media='all' />
       <link rel='stylesheet' id='cmb2-styles-css'  href='http://localhost/..
       ```
   
 * Here’s what my functions look like
 *     ```
       function load_custom_wp_admin_style() {
               wp_register_style( 'cmb2-override', get_template_directory_uri() . '/admin/cmb2-style.css');
               wp_enqueue_style( 'cmb2-override' );
       }
       add_action( 'admin_enqueue_scripts', 'load_custom_wp_admin_style' );
       ```
   
 * By the way, if I would like to load the custom-style only when there are cmb2
   custom fields which page should I target?
 * Thanks!
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/setting-text-field-width/#post-6380421)
 * **[@srmahmud2](https://wordpress.org/support/users/srmahmud2/)**: If you require
   assistance then, as per the [Forum Welcome](http://codex.wordpress.org/Forum_Welcome#Where_To_Post),
   please post your own topic instead of tagging onto someone else’s. This topic
   is 3 months old & has been resolved, so will no longer be monitored by the plugin’s
   author.
 *  [srmahmud2](https://wordpress.org/support/users/srmahmud2/)
 * (@srmahmud2)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/setting-text-field-width/#post-6380422)
 * Hi esmi,
 * Thanks for remindere. I was a little confuse should comment here or where. Never
   mind mean I have resolved one of my issue.
 * Will post the rest as prescribed.
 * Regards.
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [10 years, 4 months ago](https://wordpress.org/support/topic/setting-text-field-width/#post-6380423)
 * with your wp_register_style, put “cmb2-styles” as a dependency for your own CSS
   file. That should force them to be loaded after CMB2’s.
 * You’d need to do some sort of current screen checking to conditionally load the
   CSS file itself. Not sure offhand where in the admin this is meant for, meaning
   post editor pages, options page, etc.
 *  [srmahmud2](https://wordpress.org/support/users/srmahmud2/)
 * (@srmahmud2)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/setting-text-field-width/#post-6380424)
 * Thanks for you prompt reply.
 * any one who comes later please follow this thread hear [how to float left text-fields one another and adding placeholder instead of label](https://wordpress.org/support/topic/text-field-float-left-and-placeholder).
 *  Plugin Author [Justin Sternberg](https://wordpress.org/support/users/jtsternberg/)
 * (@jtsternberg)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/setting-text-field-width/#post-6380425)
 * If you want to remove the field names, you can specify `'show_names' => false`
   on the metabox config array: [https://github.com/WebDevStudios/CMB2/blob/master/example-functions.php#L87](https://github.com/WebDevStudios/CMB2/blob/master/example-functions.php#L87)

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Setting Text Field Width?’ is closed to new replies.

 * ![](https://ps.w.org/cmb2/assets/icon.svg?rev=2866672)
 * [CMB2](https://wordpress.org/plugins/cmb2/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cmb2/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cmb2/)
 * [Active Topics](https://wordpress.org/support/plugin/cmb2/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cmb2/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cmb2/reviews/)

## Tags

 * [cmb2 plugin](https://wordpress.org/support/topic-tag/cmb2-plugin/)

 * 9 replies
 * 5 participants
 * Last reply from: [Justin Sternberg](https://wordpress.org/support/users/jtsternberg/)
 * Last activity: [10 years, 4 months ago](https://wordpress.org/support/topic/setting-text-field-width/#post-6380425)
 * Status: resolved